Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Linking a static library to my code base - Please help
Linking a static library to my code base - Please help [message #172916] Fri, 14 July 2006 06:19 Go to next message
Eclipse UserFriend
Originally posted by: mailsiraj.gmail.com

Note: I have gone through almost all the article on CDT and spent a lot of
time at CDT forum, trying out the many suggestions to solve the static
library linking problem.

I have a C++ project set up in Visual studio, which is working fine. Being
a fan of Eclipse, I have tried to port it to Eclipse CDT (a Managed Make
C++ tutorial), but despite my repeated attempts, I am not able to do it,
since I am getting some linking errors in the eclipse CDT environment.

I have a third-party library called SNOCAPI.LIB which exposes an API,
which is used in my code. But even after I included this library under the
linker settings, I am still getting errors. (To include the library, I
tried to specify the string "SNOCAPI" on the Linker library settings and
added the path to Library search path). Still the errors didn't stop.
Somebody in the forum suggested that I add the full path (which looks
something like "C:\learn\SNOCAPI.LIB") to Miscellaneous -> Linker flags.
Even then, the error is still persistent.

Here is a sample of the error...

undefined reference to `__imp___ZN6snocap6SnoMan11getInstanceEv'

Any help in this regard is highly appreciated. I have been trying to get
it working for a painfully long amount of time...
Re: Linking a static library to my code base - Please help [message #172924 is a reply to message #172916] Fri, 14 July 2006 08:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ed_06.tantec.de

> I have a third-party library called SNOCAPI.LIB which exposes an API,
> which is used in my code.

I'm not sure about the details, because it should be possible to use
Eclipse even with the VC-Compiler, which should know *.lib-files, but
working with MinGW, there are "Unix-style-Libraries" needed, like
"libSNOCAPI.a". So if your SNOCAPI is a static library, I think you need
the source to recompile it for getting a "libSNOCAPI.a". If it is an
import library for a dll it is another option of making the lib - I had
this problem recently and found a morons guide for guys like me. ;o)

http://www.emmestech.com/software/cygwin/pexports-0.43/moron 1.html

It made my day. :o)

If there is no source for your static library, maybe it is possible to
use VC for wrapping it into a dll, you can import in morons way. But
this is just an idea, not a thing, I tested myself - so you would need
good luck.
Re: Linking a static library to my code base - Please help [message #173016 is a reply to message #172924] Mon, 17 July 2006 02:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mailsiraj.gmail.com

Is creating a libX.a file is needed on the Windows Platform as well? I am
working on Windows platform.

I am trying out the steps that are described in the moron's document. But
the erros are persistent...
Re: Linking a static library to my code base - Please help [message #173023 is a reply to message #173016] Mon, 17 July 2006 05:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ed_06.tantec.de

> Is creating a libX.a file is needed on the Windows Platform as well? I
> am working on Windows platform.

I'm working on Windows too, using MinGW with GCC compiler. For that I
need libX.a files, but the details I'm not sure about regard to the use
of another comppiler/ linker - maybe the VC compiler. I think for that
case it should be possible to use X.lib files, but I never tried.

> I am trying out the steps that are described in the moron's document.
> But the erros are persistent...

The only other linker problem I know regards to the sequence of linked
files - if there is a lib using another lib, in the linker list the used
lib must follow the lib it is using.
Re: Linking a static library to my code base - Please help [message #173031 is a reply to message #173023] Mon, 17 July 2006 07:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mailsiraj.gmail.com

Hi Egberts,

First of all, thanks a lot for the time that you are putting in to help me
out.

> I'm working on Windows too, using MinGW with GCC compiler. For that I
> need libX.a files.
I also use the same combination - MinGW with GCC compiler.

>> I am trying out the steps that are described in the moron's document.
>> But the erros are persistent...
> The only other linker problem I know regards to the sequence of linked
> files - if there is a lib using another lib, in the linker list the used
> lib must follow the lib it is using.
The same error that the there are undefined references still persist. I am
not using more than one library file. So, I don't think that it is problem.

Let me describe what I have done. If u can help me out, that would be
great. I have gone through both the article that you have pointed to and a
few other posts on cygwin on exporting to DEF files and still could not
make it work.

I have run the following command to get the .def file
>pexports SNOCAPI.DLL | sed 's/^_//' > snocap.def
I have tried this command both with sed option and without it as well.

Then, I have run the dlltool to create the .a file from .def file
>dlltool --dllname SNOCAPI.dll --def snocap.def --output-lib libsnocap.a

Then, I have run the g++ linker using the following command...
g++ -LD:\Downloads\pexports-0.43\bin
-shared -oTestPrjCPP.dll ./JavaInterfacer.o
/SnocapInitializer.o ./SnocapIntegrator.o -lsnocap

the libsnocap.a file resides in the folder D:\Download\pexports-0.42\bin
as specified in -L switch.

I am getting the following error....
>undefined reference to `__imp___ZN6snocap6SnoMan11getInstanceEv'

Here are the contents of snocap.def. The file looks different from the
example def file shown in the moron's guide...
LIBRARY SNOCAPI.dll
EXPORTS
??0SnoMan@snocap@@QAE>@ABV01@@Z
??0SnoMan@snocap@@QAE>@XZ
??0TimeStamp@@QAE>@ABV0@@Z
??0TimeStamp@@QAE>@XZ
??1SnoMan@snocap@@QAE>@XZ
??1TimeStamp@@MAE>@XZ
??4SnoMan@snocap@@QAEAAV01>@ABV01@@Z
??4TimeStamp@@QAEAAV0>@ABV0@@Z
??7SnoMan@snocap@@6B@ DATA
??7TimeStamp@@6B@ DATA
?Create@TimeStamp@@SAPAV1>@HHHHHHH>@Z
?Destroy@TimeStamp@@SAXAAPAV1@@Z
?getInstance@SnoMan>@snocap@@SAPAV12>@XZ

Please do help me if you can...thanks...
Re: Linking a static library to my code base - Please help [message #173068 is a reply to message #173031] Mon, 17 July 2006 09:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ed_06.tantec.de

>> undefined reference to `__imp___ZN6snocap6SnoMan11getInstanceEv'
>
> Here are the contents of snocap.def. The file looks different from the
> example def file shown in the moron's guide...
> LIBRARY SNOCAPI.dll
> EXPORTS
> ??0SnoMan@snocap@@QAE>@ABV01@@Z
> ??0SnoMan@snocap@@QAE>@XZ
> ??0TimeStamp@@QAE>@ABV0@@Z
> ??0TimeStamp@@QAE>@XZ
> ??1SnoMan@snocap@@QAE>@XZ
> ??1TimeStamp@@MAE>@XZ
> ??4SnoMan@snocap@@QAEAAV01>@ABV01@@Z
> ??4TimeStamp@@QAEAAV0>@ABV0@@Z
> ??7SnoMan@snocap@@6B@ DATA
> ??7TimeStamp@@6B@ DATA
> ?Create@TimeStamp@@SAPAV1>@HHHHHHH>@Z
> ?Destroy@TimeStamp@@SAXAAPAV1@@Z
> ?getInstance@SnoMan>@snocap@@SAPAV12>@XZ

This looks a little curious (all the @-signs) and most important - there
is nothing looking like the missing reference. Do you know the
dependency walker (http://www.dependencywalker.com/)? This tools shows
all the function names of the dll and maybe helps to get a better def file.
I'm out of ideas and regarding to dll und import library now you know as
much as I do. The only difference - for me it worked. ;o)

Good luck,

Ed
Re: Linking a static library to my code base - Please help [message #173132 is a reply to message #173068] Tue, 18 July 2006 00:24 Go to previous message
Eclipse UserFriend
Originally posted by: mailsiraj.gmail.com

Hi Egberts,

> dependency walker (http://www.dependencywalker.com/)? This tools shows
> all the function names of the dll and maybe helps to get a better def file.
> I'm out of ideas and regarding to dll und import library now you know as
> much as I do. The only difference - for me it worked. ;o)

I tried Dependency Walker as well. But no way out of this plight. Thanks
for all the help that you have extended. Thanks again Ed...
Previous Topic:MinGW 3.2.3 Include Errors
Next Topic:The editor tabs disappear
Goto Forum:
  


Current Time: Tue Sep 16 13:21:28 EDT 2025

Powered by FUDForum. Page generated in 0.05224 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top