Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: Ethalides on November 05, 2018, 07:31:35 pm

Title: Linking files problem
Post by: Ethalides on November 05, 2018, 07:31:35 pm
Hello,
I'm trying to link my program to a library and a header (that I wrote). So I tried using project-> add files  and adding my source code and my header files to the project. They seem to be in the project, but when I try to compile, it doesn't work. I'm getting weird errors like "

obj\Debug\Matrice_librairie.o||In function `Z11scalar_multRKSt6vectorIdSaIdEEiid':|
C:\Users\Etudiant\Desktop\Calcul_matriciel\Matrice_librairie.cpp|33|undefined reference to `__gxx_personality_sj0'|
C:\Users\Etudiant\Desktop\Calcul_matriciel\Matrice_librairie.cpp|33|undefined reference to `_Unwind_SjLj_Register'|
C:\Users\Etudiant\Desktop\Calcul_matriciel\Matrice_librairie.cpp|39|undefined reference to `_Unwind_SjLj_Resume'|
C:\Users\Etudiant\Desktop\Calcul_matriciel\Matrice_librairie.cpp|39|undefined reference to `_Unwind_SjLj_Unregister'|

"

I don't understand how to fix it, could anyone help me ?

I hope I was allowed to ask this in here, I wasn't sure the problem is from code::blocks :/

Thanks!
Title: Re: Linking files problem
Post by: stahta01 on November 05, 2018, 07:38:39 pm
Hello,
I'm trying to link my program to a library and a header (that I wrote). So I tried using project-> add files  and adding my source code and my header files to the project. They seem to be in the project, but when I try to compile, it doesn't work. I'm getting weird errors like "

obj\Debug\Matrice_librairie.o||In function `Z11scalar_multRKSt6vectorIdSaIdEEiid':|
C:\Users\Etudiant\Desktop\Calcul_matriciel\Matrice_librairie.cpp|33|undefined reference to `__gxx_personality_sj0'|
C:\Users\Etudiant\Desktop\Calcul_matriciel\Matrice_librairie.cpp|33|undefined reference to `_Unwind_SjLj_Register'|
C:\Users\Etudiant\Desktop\Calcul_matriciel\Matrice_librairie.cpp|39|undefined reference to `_Unwind_SjLj_Resume'|
C:\Users\Etudiant\Desktop\Calcul_matriciel\Matrice_librairie.cpp|39|undefined reference to `_Unwind_SjLj_Unregister'|

"

I don't understand how to fix it, could anyone help me ?

I hope I was allowed to ask this in here, I wasn't sure the problem is from code::blocks :/

Thanks!

Compile the program and the library using the same compiler!

Remember to re-build both program and library.

Tim S.
Title: Re: Linking files problem
Post by: Ethalides on November 05, 2018, 07:49:19 pm
Thanks for your reply.
I've checked the settings, and I'm using the same compiler for both (GNU GCC compiler). And when I compile one file at a time, there doesn't seem to be any mistake, but when compiling the project, I'm getting the same error messages...
Title: Re: Linking files problem
Post by: sodev on November 05, 2018, 09:18:59 pm
There are hundreds of GNU GCC compiler and most of them are not compatible with each other :P.

Your error message looks pretty much like you are mixing code that is compiled with SJLJ exception handling and DWARF exception handling (or even SEH?). Make sure that you REALLY use the same compiler, at least use the same exception handling model. The MinGW packages usually contain this information in the directory name, also a gcc --version does output that information.