On Windows 7, How do you reference a "static library" (a dot lib) in NetBeans

C

clusardi2k

I'm using Windows 7, NetBeans 7.1.2 and the C:\MinGW\bin\g++.exe compiler/linker.

I have been trying to reference a static library (file.lib) using linker options such as "-l" and "-L". All attempts have been unsuccessful (one possible reason is) because the "-l" option only takes the name of the library (without a leading "lib" in the filename and no suffix) and probably not a path to the library file. The "L" option takes a path to the folder containing the library, but it does not work for me.

http://mingw.org/wiki/LibraryPathHOWTO

My question is how do you reference a static library within NetBeans?

You can modify the project's linking options by right clicking on the project and selecting properties. From there, you can specify a library folder, a specific library file, or you can enter a specific linker option such as "-lfile".

I have tried various ways to get my project to use the dot lib without success. When I build the project, I get a lot of undefined references.

Thanks
 
A

Andreas Leitgeb

I'm using Windows 7, NetBeans 7.1.2 and the C:\MinGW\bin\g++.exe compiler/linker.
I have tried various ways to get my project to use the dot lib without success.
When I build the project, I get a lot of undefined references.

Have you tried passing the full pathname of the "dot lib" as
argument to the g++ call without any extra options? (Just an
idle guess on my side.)

If it works, then be happy, otherwise be aware that g++
and "dot lib"s aren't really on topic here in a Java newsgroup.
 
A

Arne Vajhøj

I'm using Windows 7, NetBeans 7.1.2 and the C:\MinGW\bin\g++.exe compiler/linker.

I have been trying to reference a static library (file.lib) using linker options such as "-l" and "-L". All attempts have been unsuccessful (one possible reason is) because the "-l" option only takes the name of the library (without a leading "lib" in the filename and no suffix) and probably not a path to the library file. The "L" option takes a path to the folder containing the library, but it does not work for me.

http://mingw.org/wiki/LibraryPathHOWTO

My question is how do you reference a static library within NetBeans?

You can modify the project's linking options by right clicking on the project and selecting properties. From there, you can specify a library folder, a specific library file, or you can enter a specific linker option such as "-lfile".

I have tried various ways to get my project to use the dot lib without success. When I build the project, I get a lot of undefined references.

g++ -L\foo -lbar z.cpp

will look for \foo\libbar.a

g++ z.cpp \foo\bar.lib

should look for \foo\bar.lib

Arne
 
R

Roedy Green

My question is how do you reference a static library within NetBeans?

You use JNI. You have to write some Java glue code. You put all your
C/C++ in a DLL. You use System.load or System.loadlibrary

see http://mindprod.com/jgloss/jni.html
--
Roedy Green Canadian Mind Products
http://mindprod.com
Why do so many operating systems refuse to define a standard
temporary file marking mechanism? It could be a reserved lead character
such as the ~ or a reserved extension such as .tmp.
It could be a file attribute bit. Because they refuse, there is no
fool-proof way to scan a disk for orphaned temporary files and delete them.
Further, you can't tell where the orhaned files ame from.
This means the hard disks gradually fill up with garbage.
 
A

Arne Vajhøj

You use JNI. You have to write some Java glue code. You put all your
C/C++ in a DLL. You use System.load or System.loadlibrary

Does that reference a static library in NetBeans??

:)

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top