Adding a .dll to a NetBeans 7.0 C project. Unable to view .dll

1.5k views Asked by At

I am trying to read a .wav file and hence need to include the libsndfile binary in my project. I am using NetBeans 7.0 and the Tools->Library->Add new library option doesnt work since the Add library button is disabled.

I tried adding the path of the header file to the Project->Build properties and the code compiled. But when I try to add the .dll in a similar way via Project->Linker properties NetBeans is unable to find the .dll. If i navigate to the folder from MyComputer->..i can see the .dll/ However NetBeans doesn't display it.

I am using a Win 7 64 bit machine & I have setup the appropriate libsndfile binary. Been at it for a day now. Would appreciate any help.

Thanks, Neeraj

2

There are 2 answers

1
Acn On

DLL doesnotrequires setting of class path. So you can load a DLL from local file system. Copy the DLL and go to the file explorer tab strip and paste the file.

0
alpereira7 On

First you have to check that your compiler version (32 or 64 bit) matches libsndfile version. I suppose you did it correctly.

I also suppose you correctly added the sndfile.h to the include path.

You will need two library files actually. I think you forgot the one to compile properly.

Compiling and Linking (.lib file)

Note that Netbeans 7.0 doesn't accept .lib files and you need to link the .lib file for your project to compile. So, in C:\Program Files\Mega-Nerd\libsndfile\lib you need to copy libsndfile-1.lib and rename the .lib extension to .a.

Then, in Poject Properties > Build > Linker > Additional Libraries Directories add the path to the \lib directory. For me it's Program Files/Mega-Nerd/libsndfile/lib.

A few lines below, you'll have Poject Properties > Build > Linker > Libraries. Specify the location of the library file named libsndfile-1.a, for me it's C:\Program Files\Mega-Nerd\libsndfile\lib\libsndfile-1.a.

Now it should at least compile.

Executing (.dll)

Now, it likely will not execute even if it compiled. That's because the .dll file is needed to execute the final .exe. Simply copy the libsndfile-1.dll file (for me it's in C:\Program Files\Mega-Nerd\libsndfile\bin) to your project, next to the .exe file. For me, it's in C:\proj\dist\Debug\Cygwin-Windows\proj.exe.

Edit: I checked with the today's 8.2 version of NetBeans, and the procedure is exactly the same.