MinGW Linking GUI Program

This is a discussion on MinGW Linking GUI Program within the Tech Board forums, part of the Community Boards category; I'm trying to make a Windows GUI program under MinGW on XPSP2. LD gives undefined reference errors to the WinAPI ...

  1. #1
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465

    MinGW Linking GUI Program

    I'm trying to make a Windows GUI program under MinGW on XPSP2. LD gives undefined reference errors to the WinAPI functions I use. Here's my makefile:

    Code:
    CC = g++
    LD = ld
    
    LIBPATH = "C:\Program Files\Microsoft Platform SDK\Lib\"
    LIBS    = gdi32.lib, kernel32.lib, user32.lib, ws2_32.lib
    
    CXXFLAGS = -c -Wall
    LDFLAGS =  --subsystem windows -e _WinMain@16 -L $(LIBPATH) -l $(LIBS)
    
    all: test
    
    test: test.o util.o
    	$(LD) test.o util.o -o test.exe $(LDFLAGS) 
    
    test.o: test.cpp main.h
    	$(CC) $(CXXFLAGS) test.cpp main.h
    
    util.o: util.cpp main.h
    	$(CC) $(CXXFLAGS) util.cpp main.h 
    
    clean:
    	rm -rfv test.exe *o
    Ends up resolving to this command, giving these errors

    ld test.o util.o -o test.exe --subsystem windows -e _WinMain@16 -L "C:\Program Files\Microsoft Platform SDK\Lib\" -l gdi32.lib
    test.o(.text+0x2c):test.cpp: undefined reference to `GetStockObject@4'
    test.o(.text+0x62):test.cpp: undefined reference to `LoadIconW@8'
    test.o(.text+0x7c):test.cpp: undefined reference to `LoadIconW@8'
    test.o(.text+0x96):test.cpp: undefined reference to `LoadCursorW@8'
    test.o(.text+0xa7):test.cpp: undefined reference to `RegisterClassExW@4'
    test.o(.text+0x122):test.cpp: undefined reference to `CreateWindowExW@48'
    test.o(.text+0x149):test.cpp: undefined reference to `ShowWindow@8'
    test.o(.text+0x157):test.cpp: undefined reference to `UpdateWindow@4'
    test.o(.text+0x17d):test.cpp: undefined reference to `GetMessageW@16'
    test.o(.text+0x18f):test.cpp: undefined reference to `TranslateMessage@4'
    test.o(.text+0x19d):test.cpp: undefined reference to `DispatchMessageW@4'
    test.o(.text+0x1ef):test.cpp: undefined reference to `DestroyWindow@4'
    test.o(.text+0x207):test.cpp: undefined reference to `PostQuitMessage@4'
    test.o(.text+0x233):test.cpp: undefined reference to `DefWindowProcW@16'
    make: *** [test] Error 1

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    It's unusual to invoke ld directly as g++ does so implicitly. Also, if you use -mwindows as a linker switch the usual libs will be linked. You also seem to be naming non-mingw libs - recall that mingw libs are prefixed with 'lib' and have an 'a' (for archive) extension eg. libgdi32.a, libkernel32.a etc. The usual syntax for mingw libs is -l(lowercase 'L') followed by the lib name eg -lgdi32, -lkernel32 etc.(but the -mwindows flags takes care of those). Also you have '--sybsystem windows'; it should be --subsystem, windows but, once more -mwindows is a synonym for it - in any event you'd normally pass such linker flags via gcc/g++ as -Wl,--subsystem,windows. Taking those points into consideration, your makefile becomes something like(not tested):
    Code:
    CC = g++
    LD = ld
    
    LIBPATH = "C:\Program Files\Microsoft Platform SDK\Lib\"
    LIBS    = -lws2_32
    
    CXXFLAGS = -c -Wall
    LDFLAGS =  -mwindows -L $(LIBPATH) $(LIBS)
    
    all: test
    
    test: test.o util.o
    	$(CC) test.o util.o -o test.exe $(LDFLAGS) 
    
    test.o: test.cpp main.h
    	$(CC) $(CXXFLAGS) test.cpp main.h
    
    util.o: util.cpp main.h
    	$(CC) $(CXXFLAGS) util.cpp main.h 
    
    clean:
    	rm -rfv test.exe *o
    My general mingw makefile might be of some interest to you, too.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    I was trying -mwindows before and it was saying something like

    unsupported platform
    supported platforms: ie386p

    That's just from my memory. That may have been when I put that flag into ld instead of g++. Anyways, your solution works great, would I want to use mingw libraries over psdk ones? Is it really subsystem, window? It seems like it's passing parameters thorugh the linker with the Wl option with the commas. When I put a comma into the switch in ld, it says:

    ld: unrecognized option '--subsystem,'
    ld: use the --help option for usage information
    make: *** [test] Error 1

    ld --help

    ...

    --subsystem <name>[:<version>] Set required OS subsystem [& version]

    It would be nifty if I could figure out how to manually do link things and specify the subsystem with ld, but I am still very much thankful for having -mwindows working now. Also, your makefile is extremely clean, I will probably incorporate it into my projects.

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>would I want to use mingw libraries over psdk ones?<<

    I would but, if it works for you... You may want to check the psdk licence to make sure there are no restrictions on distributing applications etc.

    >>It seems like it's passing parameters thorugh the linker with the Wl option with the commas. When I put a comma into the switch in ld<<

    Sorry, my mistake. The syntax I suggested (Wl) is indeed the method for passing switches to the linker via the compiler.

    Since this is essentially a compiler configuration rather than a c++ programming language thread, I'm moving it to the tech board.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Good deal. This still stumping me a little bit. The linker doesn't seem like it's even trying to link the libraries I pass to it. I fixed some silly errors in the makefile, and it is now this:

    Code:
    CC = g++
    LD = ld
    
    LIBPATH := -L"C:\Program Files\Microsoft Platform SDK\Lib\"
    LIBS := -lgdi32.lib -lkernel32.lib -luser32.lib -lws2_32.lib
    
    LDFLAGS := --subsystem windows -e _WinMain@16 $(LIBPATH) $(LIBS)
    CXXFLAGS = -c -Wall
    
    all: test
    
    test: test.o util.o
    	$(LD) test.o util.o -o test.exe $(LDFLAGS) 
    
    test.o: test.cpp main.h
    	$(CC) $(CXXFLAGS) test.cpp main.h
    
    util.o: util.cpp main.h
    	$(CC) $(CXXFLAGS) util.cpp main.h 
    
    clean:
    	rm -rfv test.exe *o
    Resolves to this linkage and these errors:

    Code:
    ld test.o util.o -o test.exe --subsystem windows -e _WinMain@16 -L"C:\Program 
    Files\Microsoft Platform SDK\Lib\" -lgdi32.lib -lkernel32.lib -luser32.lib -lws2_32.lib
    test.o(.text+0x1c):test.cpp: undefined reference to `LoadCursorW@8'
    test.o(.text+0x35):test.cpp: undefined reference to `LoadIconW@8'
    test.o(.text+0x4e):test.cpp: undefined reference to `LoadIconW@8'
    test.o(.text+0x5f):test.cpp: undefined reference to `GetStockObject@4'
    test.o(.text+0x155):test.cpp: undefined reference to `ShowWindow@8'
    test.o(.text+0x163):test.cpp: undefined reference to `UpdateWindow@4'
    test.o(.text+0x189):test.cpp: undefined reference to `GetMessageW@16'
    test.o(.text+0x19b):test.cpp: undefined reference to `TranslateMessage@4'
    test.o(.text+0x1a9):test.cpp: undefined reference to `DispatchMessageW@4'
    test.o(.text+0x21d):test.cpp: undefined reference to `DestroyWindow@4'
    test.o(.text+0x235):test.cpp: undefined reference to `PostQuitMessage@4'
    test.o(.text+0x261):test.cpp: undefined reference to `DefWindowProcW@16'
    util.o(.text+0x25):util.cpp: undefined reference to `MessageBoxW@16'
    util.o(.text+0x70):util.cpp: undefined reference to `RegisterClassExW@4'
    util.o(.text+0xdb):util.cpp: undefined reference to `CreateWindowExW@48'
    make: *** [test] Error 1
    I specify the libraries, and where to find them, and it still gives me all those unresolved references. I don't need to specify libraries to load from at compilation, but the linker doesn't seem to recognize that it needs to link these libraries too, wierd!

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Using g++ to implicitly invoke linker:
    Code:
    CC = g++
    #LD = ld
    
    LIBPATH  = "C:\Program Files\Microsoft Platform SDK\Lib\"
    LIBS     = $(LIBPATH)/Gdi32.Lib $(LIBPATH)/kernel32.lib $(LIBPATH)/user32.lib $(LIBPATH)/ws2_32.lib
    
    LDFLAGS  = -Wl,--subsystem,windows -L$(LIBPATH) $(LIBS)
    CXXFLAGS = -c -Wall
    
    all: test
    
    test: test.o util.o
    	$(CC) test.o util.o -o test.exe $(LDFLAGS) 
    
    test.o: test.cpp main.h
    	$(CC) $(CXXFLAGS) test.cpp main.h
    
    util.o: util.cpp main.h
    	$(CC) $(CXXFLAGS) util.cpp main.h
    Using the linker directly, as you seem to be intent on:
    Code:
    CC = g++
    LD = ld
    
    LIBPATH  = "C:\Program Files\Microsoft Platform SDK\Lib\"
    LIBS     = $(LIBPATH)/Gdi32.Lib $(LIBPATH)/kernel32.lib $(LIBPATH)/user32.lib $(LIBPATH)/ws2_32.lib
    
    LDFLAGS  = --subsystem windows -L$(LIBPATH) $(LIBS)
    CXXFLAGS = -c -Wall
    
    all: test
    
    test: test.o util.o
    	$(LD) test.o util.o -o test.exe $(LDFLAGS) 
    
    test.o: test.cpp main.h
    	$(CC) $(CXXFLAGS) test.cpp main.h
    
    util.o: util.cpp main.h
    	$(CC) $(CXXFLAGS) util.cpp main.h
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  7. #7
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    With LIBPATH as LIBPATH = "C:\Program Files\Microsoft Platform SDK\Lib\" is said that Files\Microsoft could not be found, so I made it LIBPATH = "C:\Program Files\Microsoft Platform SDK\Lib" and I got

    Code:
    ld test.o util.o -o test.exe --subsystem windows -L"C:\Program Files\Microsoft Platform SDK\Lib" "C:\Program Files\Microsoft Platform SDK\Lib"/Gdi32.L
    ib "C:\Program Files\Microsoft Platform SDK\Lib"/kernel32.lib "C:\Program Files\Microsoft Platform SDK\Lib"/user32.lib "C:\Program Files\Microsoft Pla
    tform SDK\Lib"/ws2_32.lib
    ld: warning: cannot find entry symbol _WinMainCRTStartup; defaulting to 00401000
    test.o(.text+0x1c):test.cpp: undefined reference to `LoadCursorW@8'
    test.o(.text+0x35):test.cpp: undefined reference to `LoadIconW@8'
    test.o(.text+0x4e):test.cpp: undefined reference to `LoadIconW@8'
    test.o(.text+0x5f):test.cpp: undefined reference to `GetStockObject@4'
    test.o(.text+0x155):test.cpp: undefined reference to `ShowWindow@8'
    test.o(.text+0x163):test.cpp: undefined reference to `UpdateWindow@4'
    test.o(.text+0x189):test.cpp: undefined reference to `GetMessageW@16'
    test.o(.text+0x19b):test.cpp: undefined reference to `TranslateMessage@4'
    test.o(.text+0x1a9):test.cpp: undefined reference to `DispatchMessageW@4'
    test.o(.text+0x21d):test.cpp: undefined reference to `DestroyWindow@4'
    test.o(.text+0x235):test.cpp: undefined reference to `PostQuitMessage@4'
    test.o(.text+0x261):test.cpp: undefined reference to `DefWindowProcW@16'
    util.o(.text+0x25):util.cpp: undefined reference to `MessageBoxW@16'
    util.o(.text+0x70):util.cpp: undefined reference to `RegisterClassExW@4'
    util.o(.text+0xdb):util.cpp: undefined reference to `CreateWindowExW@48'
    make: *** [test] Error 1
    
    C:\test>
    Um. I can't tell whether it's like, a problem with a space being in the path. I tried using mingw's win32 libs:

    Code:
    CC = g++
    LD = ld
    
    #LIBPATH  = "C:\Program Files\Microsoft Platform SDK\Lib\"
    #LIBS     = -l"C:\Program Files\Microsoft Platform SDK\Lib\gdi32.Lib" -l"C:\Program Files\Microsoft Platform SDK\Lib\kernel32.lib" -l"C:\Program Files\Microsoft Platform SDK\Lib\user32.lib" -l"C:\Program Files\Microsoft Platform SDK\Lib\ws2_32.lib"
    
    LIBPATH   = "C:\Development\Dev\lib"
    LIBS      = -l libgdi32.a -l libkernel32.a -l libuser32.a -l libws2_32.a
    
    
    LDFLAGS  = --subsystem windows $(LIBS)
    CXXFLAGS = -c -Wall
    
    all: test
    
    test: test.o util.o
    	$(LD) test.o util.o -o test.exe $(LDFLAGS) 
    
    test.o: test.cpp main.h
    	$(CC) $(CXXFLAGS) test.cpp main.h
    
    util.o: util.cpp main.h
    	$(CC) $(CXXFLAGS) util.cpp main.h
    And got

    Code:
    ld test.o util.o -o test.exe --subsystem windows -l libgdi32.a -l libkernel32.a -l libuser32.a -l libws2_32.a
    ld: cannot find -llibgdi32.a
    make: *** [test] Error 1
    Why is it trying to find "-llibgdi32.a", libgdi32.a exists. Using g++ to invoke linker with your script, I got these errors, seeming to result in spaces in the path. I can not find any information about this googling.

    Code:
    [B]C:\test>make all
    g++ test.o util.o -o test.exe -Wl,--subsystem,windows -L"C:\Program Files\Microsoft Platform SDK\Lib\" "C:\Program Files\Microsoft Platform SDK\Lib\"/
    Gdi32.Lib "C:\Program Files\Microsoft Platform SDK\Lib\"/kernel32.lib "C:\Program Files\Microsoft Platform SDK\Lib\"/user32.lib "C:\Program Files\Micr
    osoft Platform SDK\Lib\"/ws2_32.lib
    g++: Files\Microsoft: No such file or directory
    g++: Platform: No such file or directory
    g++: SDK\Lib"/Gdi32.Lib: No such file or directory
    g++: C:\Program Files\Microsoft Platform SDK\Lib"/kernel32.lib C:\Program: Invalid argument
    g++: Files\Microsoft: No such file or directory
    g++: Platform: No such file or directory
    g++: SDK\Lib"/user32.lib: No such file or directory
    g++: C:\Program Files\Microsoft Platform SDK\Lib"/ws2_32.lib : Invalid argument
    make: *** [test] Error 1

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  8. #8
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Most gnu tools abhor spaces in paths but enclosing such paths in quotes usually, but not always, helps. The '-l' switch is for gcc style lib names (libxxxx.a); as I mentioned earlier in the thread, you just give the part of the lib name denoted by 'xxxx', preceded by -l, eg libgd32.a becomes -lgdi32; otherwise just specify the full lib name (and path, if required).

    Btw, how do you invoke make? From a command prompt or do you use msys?
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  9. #9
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Command prompt :x

    Am I not supposed to? I still get errors from this, so so wierd

    Code:
    CC = g++
    LD = ld
    
    #LIBPATH  = "C:\Program Files\Microsoft Platform SDK\Lib\"
    #LIBS     = -l"C:\Program Files\Microsoft Platform SDK\Lib\gdi32.Lib" -l"C:\Program Files\Microsoft Platform SDK\Lib\kernel32.lib" -l"C:\Program Files\Microsoft Platform SDK\Lib\user32.lib" -l"C:\Program Files\Microsoft Platform SDK\Lib\ws2_32.lib"
    
    LIBPATH   = "C:\Development\Dev\lib"
    LIBS      = -l gdi32.a -l kernel32.a -l user32.a -l ws2_32.a
    
    
    LDFLAGS  = --subsystem windows -L $(LIBPATH) $(LIBS)
    CXXFLAGS = -c -Wall
    
    all: test
    
    test: test.o util.o
    	$(LD) test.o util.o -o test.exe $(LDFLAGS) 
    
    test.o: test.cpp main.h
    	$(CC) $(CXXFLAGS) test.cpp main.h
    
    util.o: util.cpp main.h
    	$(CC) $(CXXFLAGS) util.cpp main.h
    Errrors

    Code:
    ld test.o util.o -o test.exe --subsystem windows -L "C:\Development\Dev\lib" -l gdi32.a -l kernel32.a -l user32.a -l ws2_32.a
    ld: cannot find -lgdi32.a
    make: *** [test] Error 1
    Even if I'm completely verbose

    Code:
    LIBS      = -l C:\Development\Dev\lib\gdi32.a -l C:\Development\Dev\lib\kernel32.a -l C:\Development\Dev\lib\user32.a -l C:\Development\Dev\lib\ws2_32.a
    It gives the errors

    Code:
    ld test.o util.o -o test.exe --subsystem windows -L "C:\Development\Dev\lib\" -l C:\Development\Dev\lib\libgdi32.a -l C:\Development\Dev\lib\kernel32.
    a -l C:\Development\Dev\lib\user32.a -l C:\Development\Dev\lib\ws2_32.a
    ld: warning: cannot find entry symbol _WinMainCRTStartup; defaulting to 00401000
    test.o(.text+0x1c):test.cpp: undefined reference to `LoadCursorW@8'
    test.o(.text+0x35):test.cpp: undefined reference to `LoadIconW@8'
    test.o(.text+0x4e):test.cpp: undefined reference to `LoadIconW@8'
    test.o(.text+0x5f):test.cpp: undefined reference to `GetStockObject@4'
    test.o(.text+0x155):test.cpp: undefined reference to `ShowWindow@8'
    test.o(.text+0x163):test.cpp: undefined reference to `UpdateWindow@4'
    test.o(.text+0x189):test.cpp: undefined reference to `GetMessageW@16'
    test.o(.text+0x19b):test.cpp: undefined reference to `TranslateMessage@4'
    test.o(.text+0x1a9):test.cpp: undefined reference to `DispatchMessageW@4'
    test.o(.text+0x21d):test.cpp: undefined reference to `DestroyWindow@4'
    test.o(.text+0x235):test.cpp: undefined reference to `PostQuitMessage@4'
    test.o(.text+0x261):test.cpp: undefined reference to `DefWindowProcW@16'
    util.o(.text+0x25):util.cpp: undefined reference to `MessageBoxW@16'
    util.o(.text+0x70):util.cpp: undefined reference to `RegisterClassExW@4'
    util.o(.text+0xdb):util.cpp: undefined reference to `CreateWindowExW@48'
    make: *** [test] Error 1
    It does not like the actual filenames either

    Code:
    LIBS      = -l C:\Development\Dev\lib\libgdi32.a -l C:\Development\Dev\lib\libkernel32.a -l C:\Development\Dev\lib\libuser32.a -l C:\Development\Dev\lib\libws2_32.a
    Same errors

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  10. #10
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Don't use the '-l' in that context - just list the libs.

    edit:

    ie either have:
    Code:
    LIBS = -lgdi32 -lkernel32 -luser32 -lws2_32
    or
    Code:
    #for testing purposes
    LIBS = "C:\Program Files\Microsoft Platform SDK\Lib\gdi32.Lib" "C:\Program Files\Microsoft Platform SDK\Lib\kernel32.lib"
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  11. #11
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Well, this way works, direct paths to mingw win32api libs:

    Code:
    # No LIBPATH
    
    LIBS      = C:\Development\Dev\lib\libgdi32.a C:\Development\Dev\lib\libkernel32.a C:\Development\Dev\lib\libuser32.a C:\Development\Dev\lib\libws2_32.a
    
    LDFLAGS  = --subsystem windows -e _WinMain@16 $(LIBS)
    But this does not work:

    Code:
    # No LIBPATH
    
    LIBS = "C:\Program Files\Microsoft Platform SDK\Lib\gdi32.lib" "C:\Program Files\Microsoft Platform SDK\Lib\kernel32.lib"
    
    LDFLAGS  = --subsystem windows -e _WinMain@16 $(LIBS)
    And neither does this:

    Code:
    LIBPATH = -L"C:\Development\Dev\lib\"
    LIBS    = -lgdi32 -lkernel32 -luser32
    
    LDFLAGS  = --subsystem windows -e _WinMain@16 $(LIBPATH) $(LIBS)
    
    # Yielding:
    
    ld test.o util.o -o test.exe --subsystem windows -e _WinMain@16 -L"C:\Development\Dev\lib\" -lgdi32 -lkernel32 -luser32

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  12. #12
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Does getting rid of '-e _WinMain@16' work? The 'subsystem window' should ensure the entry point function is WinMain and not main.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  13. #13
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Then I get a warning about not finding the _WinMainCRTStartup.

    Code:
    kernel32.lib"
    ld: warning: cannot find entry symbol _WinMainCRTStartup; defaulting to 00401000
    test.o(.text+0x19):test.cpp: undefined reference to `LoadCursorW@8'
    test.o(.text+0x32):test.cpp: undefined reference to `LoadIconW@8'
    test.o(.text+0x4b):test.cpp: undefined reference to `LoadIconW@8'
    test.o(.text+0x5c):test.cpp: undefined reference to `GetStockObject@4'
    test.o(.text+0x12f):test.cpp: undefined reference to `ShowWindow@8'
    test.o(.text+0x13d):test.cpp: undefined reference to `UpdateWindow@4'
    test.o(.text+0x163):test.cpp: undefined reference to `GetMessageW@16'
    test.o(.text+0x175):test.cpp: undefined reference to `TranslateMessage@4'
    test.o(.text+0x183):test.cpp: undefined reference to `DispatchMessageW@4'
    test.o(.text+0x1f9):test.cpp: undefined reference to `DestroyWindow@4'
    test.o(.text+0x20a):test.cpp: undefined reference to `PostQuitMessage@4'
    test.o(.text+0x22f):test.cpp: undefined reference to `DefWindowProcW@16'
    util.o(.text+0x25):util.cpp: undefined reference to `MessageBoxW@16'
    util.o(.text+0x88):util.cpp: undefined reference to `RegisterClassExW@4'
    util.o(.text+0xfa):util.cpp: undefined reference to `CreateWindowExW@48'
    make: *** [test] Error 1
    I don't use the CRT in my program, and I don't think it's a problem.

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

  14. #14
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    This seems very strange. Could you possibly put together a minimum set of files that replicates the problem from your end so I can test it on my own machine?
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  15. #15
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    wurd.cpp

    Code:
    #include <windows.h>
    #include <tchar.h>
    
    int WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCommandLine, INT 
    	    nShow)
    {
            ::MessageBox(HWND_DESKTOP, _T("Testing"), 
                    _T("Message Box"), MB_OK);
    		
    	return 0;
    }
    Makefile

    Code:
    CC = g++
    LD = ld
    
    LIBS = "C:\Program Files\Microsoft Platform SDK\Lib\gdi32.Lib" "C:\Program Files\Microsoft Platform SDK\Lib\kernel32.lib"
    
    LDFLAGS  = --subsystem windows -e _WinMain@16 $(LIBS)
    CXXFLAGS = -c -Wall
    
    all: wurd
    
    wurd: wurd.o
    	$(LD) wurd.o -o wurd.exe $(LDFLAGS) 
    
    wurd.o: wurd.cpp
    	$(CC) $(CXXFLAGS) .cpp

    ╔╗╔╦══╦╗╔╦══╦╗
    ║╚╝║╔╗║╚╝║╔╗║║
    ║╔╗║╠╣║╔╗║╠╣╠╣
    ╚╝╚╩╝╚╩╝╚╩╝╚╩╝

    codez http://code.google.com/p/zxcvbn/

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 02:42 AM
  2. How to combine a GUI with a program
    By bikr692002 in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2006, 08:09 PM
  3. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  4. Replies: 2
    Last Post: 05-10-2002, 05:16 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21