Why are you making a mistake when trying to compile the program with this library (IUP)?

Asked

Viewed 1,634 times

5

By including a C library you are 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)) ===|

It’s not the first time I’ve had this kind of problem trying to use libraries in my programs. I set up the folders in Linker/compiler, but it’s not working. I’m using Code Blocks, but I’ve tried Dev-C++ and Netbeans and I’ve also had problems.

The library I’m using is that one and the program I tried to compile and that:

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

Updating:
I’m using Windows 10 x64 with the Mingw compiler.

I followed step-by-step, put the library in the compiler folder, and included the header file in both the project hierarchy and the compiler configuration. And yet you’re making that mistake:

"/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
  • Try to give a more descriptive title to your question, it may be the difference between attracting the attention of those who know the answer, or not...

  • Post more details of how you are compiling the code. This code is the example of the IUP project documentation, so it should work. Note that you need multiple libs, installed and accessed in order to compile, if you build on linux.

  • I used all the answers, but I haven’t solved it yet. But I’ll keep trying. Thank you all for your help.

2 answers

2

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

Try, after each change, deleting such files and recompiling from scratch, to avoid persistent errors. By overcoming this error, complete the practice.

1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.