Question

I am creating 2 projects at the moment. The first one is an executable application. The second one is a Dynamic Library. Is there a way to link the Dynamic Library to the application in Netbeans so when I run the application I can load in the Dynamic Library. I know I could just copy the built files over, but that is a pain in the ass as I need to test if it's working every minute.

Does anyone know how to do this? I'm pretty sure it's possible as it would be so useful in many cases.

Was it helpful?

Solution

Yes it's possible:

  1. Application Project -> right click -> Properties -> Linker
  2. Libraries -> ... -> Add Project -> select your library project (-> check Build and select the Configuration if necessary)
  3. Add the proper include directory at C or C++ Compiler settings
  4. Properties -> Related Projects -> ... -> at your library project there

Not sure if step #4 is required.

If you build your application project, the library project will get build too.

OTHER TIPS

An alternative is to point the project that uses the shared library to the directory where netbeans places the .so it generates from the shared library project. In other words, project 1 creates a shared library, project 2 uses it. So in netbeans right click on project2, choose

properties->linker->libraries (click "...")

then click on "add library" and navigate to the folder of project 1 that is the actual netbeans project folder -- in it there will be a "dist" directory, with children, something like "/dist/Debug/linux-x86/.so" choose that .so file

note, project 1 should be created as a netbeans "C Dynamic Library" project, in which case it will automatically pre-pend "lib" in front of the project name when it generates the .so, so that the .so file's name automatically starts with "lib"..

After that, you can update and build the two projects independently, and project 2 will always see the latest build of project 1.

Sean

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top