Adding lib path in v3.x

Discussion to talk about software related topics only.
Post Reply
SeeCwriter
Posts: 624
Joined: Mon May 12, 2008 10:55 am

Adding lib path in v3.x

Post by SeeCwriter »

I'm trying to add a path to some libraries and I keep getting linker error "cannot find -lagentlib.a".
The library is in this path: C:\Projects\nburn\Odu\SNMP\Lib

In the Eclipse Project-->Properties-->C/C++ Build-->Settings-->GNU C/C++ Linker-->Libraries-->Library search path (-L) I added this path:

"C:/Projects/nburn/Odu/SNMP/Lib"

Why doesn't that work?

I'm using v3.3.9 with a MOD5441X.
User avatar
TomNB
Posts: 576
Joined: Tue May 10, 2016 8:22 am

Re: Adding lib path in v3.x

Post by TomNB »

What is the name of the file you are trying to include? GCC is a bit strange when it comes to the library name when you use -l. The file must be prepended with lib and be of file type .a.

See https://gcc.gnu.org/onlinedocs/gcc-8.3. ... tions.html.

So, for instance, if you use -lmylib, then gcc expects the library to be named libmylib.a
SeeCwriter
Posts: 624
Joined: Mon May 12, 2008 10:55 am

Re: Adding lib path in v3.x

Post by SeeCwriter »

Prepending 'lib' to the library name didn't help.

Invoking: GNU C/C++ Linker
c:/nburn/gcc/bin/../lib/gcc/m68k-unknown-elf/8.1.0/../../../../m68k-unknown-elf/bin/ld.exe: cannot find -llibagentlib.a
c:/nburn/gcc/bin/../lib/gcc/m68k-unknown-elf/8.1.0/../../../../m68k-unknown-elf/bin/ld.exe: cannot find -llibagentsys.a
c:/nburn/gcc/bin/../lib/gcc/m68k-unknown-elf/8.1.0/../../../../m68k-unknown-elf/bin/ld.exe: cannot find -llibdemomibs.a
c:/nburn/gcc/bin/../lib/gcc/m68k-unknown-elf/8.1.0/../../../../m68k-unknown-elf/bin/ld.exe: cannot find -llibnetburner-platform-54415.a
collect2.exe: error: ld returned 1 exit status
SeeCwriter
Posts: 624
Joined: Mon May 12, 2008 10:55 am

Re: Adding lib path in v3.x

Post by SeeCwriter »

I have added my library path to Properties-->C/C++ General-->Paths and Symbols-->Library Paths tab, and to the C/C++ General-->Paths and Symbols-->Includes tab. And the path is in the C/C++ Build-->Settings-->GNU C/C++ Linker-->Libraries tab. I've verified spelling and wrapped all paths in quotes.
Linker still can't find the libraries.
There must be something very basic that I'm missing.
SeeCwriter
Posts: 624
Joined: Mon May 12, 2008 10:55 am

Re: Adding lib path in v3.x

Post by SeeCwriter »

As I suspected, it was something basic. After reading the GNU docs more carefully, I determined that the library name entered in the project properties of Eclipse does not have the prepended 'lib' to file name. While the library filename is libmylib.a, what is entered into Eclipse is mylib. No prepended 'lib' and no '.a' extension.
User avatar
TomNB
Posts: 576
Joined: Tue May 10, 2016 8:22 am

Re: Adding lib path in v3.x

Post by TomNB »

Thanks for the update. That can be a confusing point. If I might ask, what exactly do you mean by the GNU docs? We do have the text here in our docs:

https://www.netburner.com/NBDocs/Develo ... _proj.html

In the add library to a project section.

In the "Libraries Search Path" list box, add the path to the library. For example, for MOD5441x device, the path is: \nburn\platform\MOD5441X\original\lib. Note: the naming convention for gcc is as follows: the name of the library is actually libFatFile.a, but in the Libraries entry box you only use what comes after "lib" and do not use the .a suffix. In this case, we just use "FatFile".


Is there someplace else you looked that we could put in more information to make that easier for people to find? I think this thread will be useful to future developers as well.

Thanks!
Post Reply