From: Ralph N. <rni...@se...> - 2003-01-08 18:01:33
|
I cannot get my program to link - it starts like this, so I know I'm = including the right headers... #include <windows.h> #include <commctrl.h> #include <stdio.h> #include "resource.h" I use a Make file to build it, which looks like this all: testlist.exe testlist.exe: testlist.cpp g++ -s -mwindows -lcomctl32 -D_WIN32_IE=3D0x0401 testlist.cpp -o = testlist.exe This is the output I get: g++ -s -mwindows -lcomctl32 -D_WIN32_IE=3D0x0401 testlist.cpp -o = testlist.exe C:\DOCUME~1\rn\LOCALS~1\Temp/ccgNaaaa.o(.text$_ZN12MyWindowsDlg7DoModalEP= 6HWND__+0x35):testlist.cpp: undefined reference to = `InitCommonControlsEx@4' make: *** [testlist.exe] Error 1 I looked inside libcomctl32.a, and verified that the symbol = '_InitCommonControlsEx@4', so everything seems like it should work, but = I was unable to determine if the underscore was significant. Thanks for any answers! |
From: Andrew S. <ac...@sy...> - 2003-01-08 18:16:00
|
> -----Original Message----- > From: min...@li... > [mailto:min...@li...]On Behalf Of Ralph > Nichols > Sent: January 8, 2003 13:01 > To: min...@li... > Subject: [Mingw-users] undefined reference to 'InitCommonControlsEx@4' > > <snipped> > > testlist.exe: testlist.cpp > g++ -s -mwindows -lcomctl32 -D_WIN32_IE=0x0401 testlist.cpp > -o testlist.exe > The order in which objects are listed on the command line is relevant. In this instance, your testlist.cpp requires some objects specified by libcomctl32.a, therefore, the -lcomctl32 *must* follow testlist.cpp. e.g. g++ -s -mwindows -D_WIN32_IE=0x0401 -o testlist.exe testlist.cpp -lcomctl32 As a general rule, you should always list the libraries last. In cases where your libraries depend on other libraries, the same still holds true. <snipped> > > Thanks for any answers! > In the future, please do a search of the archives first. Virtually the same question was asked by Nuno Sousa (and answered by Max Bowsher) on Jan 4th. |
From: Benjamin R. <Ben...@ep...> - 2003-01-08 18:23:15
|
Hi Ralph, "Ralph Nichols" <rni...@se...> writes: > I use a Make file to build it, which looks like this > > all: testlist.exe > > testlist.exe: testlist.cpp > g++ -s -mwindows -lcomctl32 -D_WIN32_IE=0x0401 testlist.cpp -o > testlist.exe The order of options matters. g++ doesn't consider your -l switch, it is already forgotten, when it starts to process your C++ file. Hope this helps, benny |
From: Earnie B. <ear...@ya...> - 2003-01-08 18:23:35
|
Ralph Nichols wrote: > I use a Make file to build it, which looks like this > > all: testlist.exe > > testlist.exe: testlist.cpp > g++ -s -mwindows -lcomctl32 -D_WIN32_IE=0x0401 testlist.cpp -o testlist.exe ^^^^^^^^^^ ------------------------------------------------^ Move the library to the end of the command. Command line positioning is important. Earnie. |
From: Oscar F. <of...@wa...> - 2003-01-08 18:43:54
|
"Ralph Nichols" <rni...@se...> writes: [snip] > g++ -s -mwindows -lcomctl32 -D_WIN32_IE=0x0401 testlist.cpp -o testlist.exe > C:\DOCUME~1\rn\LOCALS~1\Temp/ccgNaaaa.o(.text$_ZN12MyWindowsDlg7DoModalEP6HWND__+0x35):testlist.cpp: undefined reference to `InitCommonControlsEx@4' > make: *** [testlist.exe] Error 1 > > I looked inside libcomctl32.a, and verified that the symbol > '_InitCommonControlsEx@4', so everything seems like it should work, > but I was unable to determine if the underscore was significant. g++ -s -mwindows -D_WIN32_IE=0x0401 testlist.cpp -o testlist.exe -lcomctl32 The linker searches undefined symbols on libraries which are listed *after* the compile unit or library that requests those symbols. -- Oscar |