Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Trouble with libraries
Trouble with libraries [message #1733384] Fri, 27 May 2016 06:50 Go to next message
Philemon Diamantatos is currently offline Philemon DiamantatosFriend
Messages: 4
Registered: May 2016
Junior Member
Hello to all,

i would like your help with a problem i have with the libraries in my project.
the problem is that i cannot make eclipse connect the libraries to the source code and as a result i get either
"can not find -l library" or
"undefined reference to `_imp__function'"

could someone help me please?

thanks a lot!
Philemon

Ps: i am using Eclipse Mars.2 Release (4.5.2)
Re: Trouble with libraries [message #1733486 is a reply to message #1733384] Sat, 28 May 2016 08:39 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
So what is in the build log? Show us at least the command to the linker and the following output text.
What is the full path and name of the library you are referencing?
Is your operating system Windows? Linux? Other?

Go to this page (Project --> Properties --> Build, Settings and under the Tool settings tab)
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_prop_build_settings_tool.htm
select linker --> Libraries

The top pane is for specifying the short library name (-lxxx) and the bottom is for specifying the path to the library (-Lpath).
Enter xxx and path without the -l and -L
Understand that the -l flag (lower case L) is shorthand for specific library name formats (usually libXXX.so or libXXX.a).
See: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html

If the name doesn't fit this format then you can include the library as an additional object file to be linked. (linker --> Miscellaneous).
Re: Trouble with libraries [message #1733492 is a reply to message #1733486] Sat, 28 May 2016 13:49 Go to previous messageGo to next message
Philemon Diamantatos is currently offline Philemon DiamantatosFriend
Messages: 4
Registered: May 2016
Junior Member
Hello David,

im sorry but im not very familiar with some terms, what do you mean with what is in the build log?

the command you are asking i guess is this:
gcc "-LC:\\Users\\Falamana\\Desktop\\Eclipse\\ADC_project" -o ADC_project.exe ADC_source.o -lpicohrdl

full path to libraries: C:\Users\Falamana\Desktop\Eclipse\ADC_project
the name od the libraries are picohrdl.dll and picohrdl.lib
My operating system is windows 7.

i have done exactly as you said with the path and name and all (i think it shows at the comand above) but still, the functions i want doesnt appear to be read. the error coming out is:
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:55: undefined reference to `_imp__HRDLGetUnitInfo@16'
repeated for every single function.
Re: Trouble with libraries [message #1733501 is a reply to message #1733492] Sat, 28 May 2016 21:43 Go to previous messageGo to next message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
You left out the text following the command in the log. It contains the actual error messages.
You haven't shown the log after you made the changed to using the full path.
It's important to know how the linker's complaints are worded.

Since you are using Windows are you running with MinGW or cygwin?
This is from MinGW: http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use


EDIT:
Quote:
gcc "-LC:\\Users\\Falamana\\Desktop\\Eclipse\\ADC_project" -o ADC_project.exe ADC_source.o -lpicohrdl
:
:
i have done exactly as you said with the path and name and all (i think it shows at the comand above)

I said you need to put the full path and name on the command line. It isn't clear if you have done so.
GCC is trying to find libpicohrdl.a based on the rules for -L and -l.
Your file name doesn't follow the convention expected.

The command should be:

gcc -o ADC_project.exe ADC_source.o "C:\\Users\\Falamana\\Desktop\\Eclipse\\ADC_project\\picohrdl.lib"

You do this by putting the full path and name in the linker --> Miscellaneous dialog as an additional object file.

[Updated on: Sun, 29 May 2016 13:03]

Report message to a moderator

Re: Trouble with libraries [message #1733561 is a reply to message #1733501] Mon, 30 May 2016 07:33 Go to previous messageGo to next message
Philemon Diamantatos is currently offline Philemon DiamantatosFriend
Messages: 4
Registered: May 2016
Junior Member
I'm using MinGW and im writing in c.

ok, i will paste the whole thing:

----------------------------------------------------------------------------------------------------------------------------------
09:56:46 **** Incremental Build of configuration Debug for project ADC_project ****
Info: Internal Builder is used for build
gcc "-LC:\\Users\\Falamana\\Desktop\\Eclipse\\ADC_project" -o ADC_project.exe ADC_source.o -lpicohrdl
ADC_source.o: In function `main':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:55: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:84: undefined reference to `_imp__HRDLCloseUnit@4'
ADC_source.o: In function `SelectUnit':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:105: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:157: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:158: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:159: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:160: undefined reference to `_imp__HRDLGetUnitInfo@16'
ADC_source.o:C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:161: more undefined references to `_imp__HRDLGetUnitInfo@16' follow
ADC_source.o: In function `SelectUnit':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:206: undefined reference to `_imp__HRDLCloseUnit@4'
ADC_source.o: In function `OpenUnit':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:215: undefined reference to `_imp__HRDLOpenUnit@0'
ADC_source.o: In function `SetMains':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:227: undefined reference to `_imp__HRDLSetMains@8'
ADC_source.o: In function `SetChannels':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:392: undefined reference to `_imp__HRDLSetAnalogInChannel@20'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:401: undefined reference to `_imp__HRDLGetUnitInfo@16'
ADC_source.o: In function `SetIntervals':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:456: undefined reference to `_imp__HRDLSetInterval@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:457: undefined reference to `_imp__HRDLSetInterval@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:458: undefined reference to `_imp__HRDLSetInterval@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:459: undefined reference to `_imp__HRDLSetInterval@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:460: undefined reference to `_imp__HRDLSetInterval@12'
ADC_source.o: In function `RunBlock':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:478: undefined reference to `_imp__HRDLRun@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:481: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:497: undefined reference to `_imp__HRDLReady@4'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:505: undefined reference to `_imp__HRDLGetTimesAndValues@20'
ADC_source.o: In function `RunStream':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:553: undefined reference to `_imp__HRDLRun@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:555: undefined reference to `_imp__HRDLReady@4'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:602: undefined reference to `_imp__HRDLGetTimesAndValues@20'
ADC_source.o: In function `Adctomv':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:645: undefined reference to `_imp__HRDLGetMinMaxAdcCounts@16'
collect2.exe: error: ld returned 1 exit status

09:56:47 Build Finished (took 630ms)
------------------------------------------------------------------------------------------------------

if i use the Miscellaneous dialog, i end up with:
---------------------------------------------------------------------------------------------------------
10:30:23 **** Incremental Build of configuration Debug for project ADC_project ****
Info: Internal Builder is used for build
gcc -o ADC_project.exe ADC_source.o "..\\picohrdl.lib"
ADC_source.o: In function `main':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:55: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:84: undefined reference to `_imp__HRDLCloseUnit@4'
ADC_source.o: In function `SelectUnit':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:105: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:157: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:158: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:159: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:160: undefined reference to `_imp__HRDLGetUnitInfo@16'
ADC_source.o:C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:161: more undefined references to `_imp__HRDLGetUnitInfo@16' follow
ADC_source.o: In function `SelectUnit':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:206: undefined reference to `_imp__HRDLCloseUnit@4'
ADC_source.o: In function `OpenUnit':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:215: undefined reference to `_imp__HRDLOpenUnit@0'
ADC_source.o: In function `SetMains':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:227: undefined reference to `_imp__HRDLSetMains@8'
ADC_source.o: In function `SetChannels':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:392: undefined reference to `_imp__HRDLSetAnalogInChannel@20'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:401: undefined reference to `_imp__HRDLGetUnitInfo@16'
ADC_source.o: In function `SetIntervals':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:456: undefined reference to `_imp__HRDLSetInterval@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:457: undefined reference to `_imp__HRDLSetInterval@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:458: undefined reference to `_imp__HRDLSetInterval@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:459: undefined reference to `_imp__HRDLSetInterval@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:460: undefined reference to `_imp__HRDLSetInterval@12'
ADC_source.o: In function `RunBlock':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:478: undefined reference to `_imp__HRDLRun@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:481: undefined reference to `_imp__HRDLGetUnitInfo@16'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:497: undefined reference to `_imp__HRDLReady@4'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:505: undefined reference to `_imp__HRDLGetTimesAndValues@20'
ADC_source.o: In function `RunStream':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:553: undefined reference to `_imp__HRDLRun@12'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:555: undefined reference to `_imp__HRDLReady@4'
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:602: undefined reference to `_imp__HRDLGetTimesAndValues@20'
ADC_source.o: In function `Adctomv':
C:\Users\Falamana\Desktop\Eclipse\ADC_project\Debug/../ADC_source.c:645: undefined reference to `_imp__HRDLGetMinMaxAdcCounts@16'
collect2.exe: error: ld returned 1 exit status
----------------------------------------------------------------------------------------------------------------------------------
Re: Trouble with libraries [message #1733614 is a reply to message #1733561] Mon, 30 May 2016 12:36 Go to previous message
David VavraFriend
Messages: 1426
Registered: October 2012
Senior Member
Well, I don't know. I haven't used Windows in some time and can't currently look into the problem.
The names look like DLL references which require an import library.
I would have thought the .lib file was it.
It may be a static library instead.
Unfortunately, both have .lib in the name but are not the same.
One contains the code and the other pointers to the code.

If you have a way to list the symbols in the .lib file it may provide a clue.
The same with your object files.
There are a number of binary tools provided for doing this in a package called GNU Binutils. They were linked from a question about MinGW so there are probably Windows versions available. You may already have them.
https://sourceware.org/binutils/docs/binutils/index.html

The code may have been compiled with import decorations. Something like __declspec(dllimport) which outputs references formatted for using an import library. They look a lot like what your symbols do. Try removing any decorations.


This is wandering off topic for this forum as it is not an Eclipse/CDT issue but a problem with using GCC. Eclipse just provided a way to build and run make. The rest is up to you.

I would think the pico people could explain what they expected you to do.
For further reading about DLLs using MinGW read the following:
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Using_ld_the_GNU_Linker/win32.html
http://stackoverflow.com/a/6480464/3312726

EDIT:
The Red Hat link has a section named "direct linking to a dll".
You might want to read it.
Maybe all you need to do is use the DLL instead of the LIB file.

[Updated on: Mon, 30 May 2016 13:45]

Report message to a moderator

Previous Topic:Advanced editor templates for C++.
Next Topic:Path Symbols invisible in the Eclipse Makefile Project
Goto Forum:
  


Current Time: Fri Apr 26 09:10:35 GMT 2024

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

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

Back to the top