Author Topic: linker error while compiling qt 4 application with code::blocks  (Read 7337 times)

kristux

  • Guest
Hello All

I get the following linker error while compiling a qt application using code::blocks

Linking executable: D:\builds\qt-apps\1.exe
/mingw/lib/crt2.o:crt1.c:(.text+0x16a): undefined reference to `__cpu_features_init'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 3 seconds)
0 errors, 0 warnings

The Qt 4.3.3 package ( downloaded from sourceforge as sources ) being used , was compiled with win32-mingw as -platform type.

The Qt package itself works fine .

I was initially getting linker error -lqtassistantclient not defined .
so i changed the value in project "build options" for link libraraies from libqtassistant.a to libqtassistant4.a as I have qt4 libraries.

Now I get the above mentioned errors.
Is it a issue with qt version incompatibility or I miss some environment paths.

Please help :(

Offline Hans Henrik

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: linker error while compiling qt 4 application with code::blocks
« Reply #1 on: January 05, 2009, 11:26:23 am »
your linking Something from dev-cpp... right?

copy crt1.o/crt2.o from dev-cpp\lib to mingw\lib (or codeblocks\lib ?? if you used "codeblocks+minGW installer")
(i had this problem 2 for a few days, and solution was nowhere on google... :o)
« Last Edit: January 05, 2009, 11:44:05 am by Hans Henrik »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: linker error while compiling qt 4 application with code::blocks
« Reply #2 on: January 06, 2009, 08:40:36 am »
your linking Something from dev-cpp... right?

copy crt1.o/crt2.o from dev-cpp\lib to mingw\lib (or codeblocks\lib ?? if you used "codeblocks+minGW installer")
(i had this problem 2 for a few days, and solution was nowhere on google... :o)

I would guess that the above suggestion is the wrong thing to do. If you do it expect future problems.

Tim S
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline Hans Henrik

  • Multiple posting newcomer
  • *
  • Posts: 23
Re: linker error while compiling qt 4 application with code::blocks
« Reply #3 on: January 07, 2009, 09:30:53 am »
well... works fine for me

can you find any program that wont compile with these?

[attachment deleted by admin]

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: linker error while compiling qt 4 application with code::blocks
« Reply #4 on: January 07, 2009, 11:54:15 am »
well... works fine for me

can you find any program that wont compile with these?

It not the compile problems, but the run-time ones to watch out for in this case.

IT is much better to replace the WHOLE MinGW run-time instead of the few files you did.
IMHO, The original problem was caused by a DLL Hell LIKE issue of having two separate MinGW Run-time versions.

The file include/_mingw.h has the define for __MINGW32_VERSION in it. This is the MinGW Run-time version number; I have found that making all my MinGW run-time versions the same works for the problem.
It is not necessary to make them the same if you are real careful on never having two or more of the MinGW run-times in the path (both [compiler/linker] search and System Path) at the same time.

I have had better luck raising the Run-time to the same version number instead of lower then to the same version number.

Note: They recently split the run-time into two separate file; I suggest downloading them both if doing the new split version.

https://sourceforge.net/project/showfiles.php?group_id=2435&package_id=11598&release_id=16693

I think mingwrt-3.15.1-mingw32.tar.gz  is the combined download while the mingwrt-3.15.1-mingw32-dev.tar.gz and mingwrt-3.15.1-mingw32-dll.tar.gz are the split download.

Tim S

« Last Edit: January 07, 2009, 11:57:22 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org