Why is it giving error when trying to compile the program with this library (IUP)?

5

Adding a C library is giving this error when trying to compile

||=== Build: Release in iup (compiler: GNU GCC Compiler) ===|
obj\Release\main.o:main.cpp|| multiple definition of 'WindowProcedure(HWND__*, unsigned int, unsigned int, long)@16'|
obj\Release\main.o:main.cpp|| first defined here|
obj\Release\main.o:main.cpp|| multiple definition of 'WinMain@16'|
obj\Release\main.o:main.cpp|| first defined here|
ld.exe||cannot find -lbgi|
ld.exe||cannot find -liup|
ld.exe||cannot find -liupcontrols|
ld.exe||cannot find -lcd|
ld.exe||cannot find -liupcd|
||=== Build failed: 9 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

This is not the first time I have this type of problem when trying to use libraries in my programs. I configured the folders in the linker / compiler, but it is not working. I'm using Code Blocks, but I already tried it on Dev-C ++ and Netbeans, and I also had problems.

The library I'm using is this and the program I tried to compile and this:

#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;
}

Update:
I'm using Windows 10x64 with the MingW compiler.

I followed the step-by-step, put the library in the compiler folder and included the header file in both the project hierarchy and the compiler configuration. Although this is giving this error:

"/C/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory '/c/Users/Carlos/Documents/NetBeansProjects/IUP'
"/C/msys/1.0/bin/make.exe"  -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/iup.exe
make.exe[2]: Entering directory '/c/Users/Carlos/Documents/NetBeansProjects/IUP'
mkdir -p dist/Debug/MinGW-Windows
gcc     -o dist/Debug/MinGW-Windows/iup build/Debug/MinGW-Windows/main.o -L/C/MinGW/lib -liup -liupcontrols -lcd -liupcd -lcomctl32 -lole32 -g -I/C/MinGW/include -include /C/MinGW/include/iup.h
build/Debug/MinGW-Windows/main.o: In function 'main':
C:\Users\Carlos\Documents\NetBeansProjects\IUP/main.c:6: undefined reference to 'IupOpen'
C:\Users\Carlos\Documents\NetBeansProjects\IUP/main.c:8: undefined reference to 'IupMessage'
C:\Users\Carlos\Documents\NetBeansProjects\IUP/main.c:10: undefined reference to 'IupClose'
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW-Windows/iup.exe] Error 1
make.exe[2]: Leaving directory '/c/Users/Carlos/Documents/NetBeansProjects/IUP'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory '/c/Users/Carlos/Documents/NetBeansProjects/IUP'
make.exe": *** [.build-impl] Error 2
    
asked by anonymous 06.09.2015 / 02:23

2 answers

2

Even after making changes to the build process, it is possible that the error persists because compilers are optimized to change compiled files as little as possible. Therefore, object files and links (.o, .obj) may still contain bugs that have already been fixed!

Try, after each change, delete such files and recompile from scratch to avoid persistent errors. By overcoming this error, end the practice.

    
11.09.2015 / 06:02
1

For this library to work you should put the library in the compiler folder and add the settings it indicates in the Linker / Compiler ... Look at this step by step: link

    
08.09.2015 / 17:39