473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Shared Library

Hi,

I am having problems with a shared library I have created to use in my MSVC project.

The main function in the library looks like this;

extern void mlfMain();

When I try to call this function from within the VC project I get an error saying 'mlfMain()' : undeclared identifier.

I call it simply by the following;

mlfMain();

I have include the shared library (meshlib.h) as;

#include "C:\...\...\meshlib.h" at the top of my file.

Can anyone point me in the right direction? Is it to do with my project settings? or something, thanks in advance.
Oct 19 '06 #1
7 1976
Anyone?

I'm sure its probably really simple but I have never done this before and I'm really struggling! Any pointers at all?

Thanks
Oct 20 '06 #2
Sorry,
Perhaps I should have mentioned that I created the library via the Matlab compiler by converting some matlab files to C files!
Oct 20 '06 #3
Banfa
9,065 Expert Mod 8TB
What sort of library is it? How is it linked with your program?
Oct 21 '06 #4
What sort of library is it? How is it linked with your program?
From the Matlab compiler I got a number of files (.dll and .lib amongst others) I am not sure what type of library it is (is there anyway to tell, I guess I should already know?) To link it to the program I have included the file path (of the .lib file) in the 'Object/library modules:' option in the link section of the project settings dialog box. However this was really no more than an act of blind desparation!

I haven't had any experience of changing project settings, linking external files - any help would be greatly appreciated. Cheers Banfa
Oct 23 '06 #5
Banfa
9,065 Expert Mod 8TB
OK a library will have at least 2 files

a header, <library>.h which contains the function and datatype declarations to be included into you code. There is not reason why a library should only have 1 header but that is the normal way to do it.

a library file, <library.lib> that contains the object code of the library, this should be included in the link stage of your program.

it may also have a <library>.dll file if the library is a dynamic link library. The dll file is not required while building the executable but is required to run it.



Things to do

1. Include the library in the link, including it in the 'Object/library modules:' setting sounds like the right thing to do.

2. Make sure the header contains an mlfMain, if it doesn't you weren't intended to call it even if it exsits in the library.
Oct 23 '06 #6
The files I that were created from the Matlab compiler were as follows;
<library>.exports, <library>.c, <library>.ctf, <library>.dll, <library>.exp, <library>.lib, <library>_mcc_component_data.c and <library>.h

not sure if the above is important but I include it just incase!


I have included the <library>.lib file in the 'Object/library modules:' option (is it the .lib file that is to be included?). I checked the header file and mlfMain is declared as follows;

extern void mlfMain();


the header file has been included in the program as;

#include "C:\..\<library>.h"


however when I compile the program I get the error message;

C:\..\meshDoc.cpp(42) : error C2065: 'mlfMain' : undeclared identifier


It is not only the mlfMain function that gives this error, there are other functions (<library>Initialize(), <library>Terminate() - which the Matlab website says are neccesary) that give the same error.

I have no idea what the problem is, again as always Banfa your help is really appreciated.
Thank you.
Oct 23 '06 #7
Banfa
9,065 Expert Mod 8TB
A quick look at the MatLab website (just go to the website and search on mlfMain) sujjests that you should also have a c file (or files) that contain you matLab defined functions including mlfMain, presumably in your case this means "<library>_mcc_component_data.c". This/these files should be compiled and linked into your program as well.

Additionally it means that there should be a C file containing the function mlfMain somewhere in your MatLab generated C source code so you can search that source code for that function.
Oct 23 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Simon | last post by:
Hello. I wanna use my dynamic shared library(built with C language) with php script. (PHP version is 4.0.6) So I making a shared library(*.so) in Solaris environment(2.7) and it is successful....
0
by: Phil | last post by:
I realize this is the php group, but I have a question that recurses back to my php install. My objective is a pure 64 bit shared object installation of php 5.0 on UltraSparc Solaris 9 compiled...
1
by: AH | last post by:
I have two functions in my shared library which are declared as follows: void setName(const std::string& str); std::vector<std::string> getInfo(); Since the code is compiled and in shared...
6
by: klh | last post by:
I have an old version of DB2 Connect (v 6) installed on a Sun Solaris (v 2.9)box. It has been installed for several years, and to me, it seems to work okay. However, an application that uses DB2...
2
by: santa19992000 | last post by:
Confusing th eword with "library", "shared library" and how to use these things in real C project, is there any small example I can take a look. Thanks.
5
by: | last post by:
hello there, what is the difference between Shared and Protected Shared? where can I read more about theses kind of variables (or whatever they are....sorry, don't know the word in eng.) ...
7
by: Steve | last post by:
Hi, We have an application framework library that gets statically linked to any applications we produce. (Windows apps, but I don't think that matters here). The framework is based heavily on...
7
by: akennis | last post by:
First of all, sorry for duplicating this post. I put it up in the alt.comp.lang.learn.c-c++ mistakenly. I'm investigating a problem whereby exceptions thrown from functions in a Shared Library...
5
by: David T. Ashley | last post by:
I've occasionally had trouble compiling and linking programs that use shared libraries. That never made a lot of sense to me, because I thought the operating system went hunting for the symbols...
3
by: S S | last post by:
Hi Are there some known issues using STL with shared library. Recently I got some crash for which the reason I dont see any, and searching on goolge shown some such issues with shared library. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.