Search code examples
cdllnetbeansiup

Netbeans - How to add external C libraries? IUP


I'm learning C, and I want to use my first external library.

Firstly I'll show the simplistic code I'm trying to compile:

 #include <stdlib.h>
 #include <iup.h>

 int main(int argc, char **argv)
 {
   IupOpen(&argc, &argv);

   IupMessage("Hello World 1", "Hello world from IUP.");

   IupClose();
   return EXIT_SUCCESS;
 }

The external library being IUP. I have downloaded the following to my documents folder:


enter image description here

Then I configured Netbeans build options by first adding the header file directory:

enter image description here

Then finally I added the .dll file:

https://prnt.sc/slf1z8

(I added a link because I thought the post was getting too long)

However, while the code no longer shows a red underline under the functions I'm trying to use, the compiler shows "cannot find -liup"

I don't know what could be going wrong. I was following this link tutorial:

http://webserver2.tecgraf.puc-rio.br/iup/en/ide_guide/netbeans.html

Thank you!


Solution

  • When you link, even using a DLL, you need a ".lib" or ".a" file depending on the compiler. In this case this library is called an import library, and contains just "pointers" to the functions in the DLL. The IUP packages include those import libraries you need. Probably you downloaded package iup-3.29_Win64_dllw6_lib.zip which include the ".a" files you will need.