Thread: Some problem with libpng and zlib

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    14

    Some problem with libpng and zlib

    Hi, im making an rpg in Opengl, and i needed som code, so that i culd use png files, with transparency.
    So i downloaded and included libpng and zlib, but when i compile my code, it says ( and my code worked before i included those lib's):

    Code:
    ------ Build started: Project: Rpg, Configuration: Debug Win32 ------
    Linking...
    SDLmain.lib(SDL_win32_main.obj) : error LNK2005: _main already defined in main.obj
    MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
    SDLmain.lib(SDL_win32_main.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _main
    Debug\Rpg.exe : fatal error LNK1120: 1 unresolved externals
    Build log was saved at "file://c:\Documents and Settings\Skrivbord\RPG\Debug\BuildLog.htm"
    Rpg - 3 error(s), 1 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    So those are the Errors in my game, please help me out here.

    //Ty in advance

  2. #2
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    You are not linking correctly with SDL and it looks as if one of your libs conflicts with the CRT.

    Check your project settings under libraries.

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    14
    I took a closer look at the SDL part, and i found out that i fotgot to include the sdl lib, so after i done that, then i youst had 1 error left :
    Code:
    ------ Build started: Project: Rpg, Configuration: Debug Win32 ------
    Compiling...
    main.cpp
    Linking...
    MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
    Embedding manifest...
    Build log was saved at "file://c:\Documents and Settings\Skrivbord\RPG\Debug\BuildLog.htm"
    Rpg - 0 error(s), 1 warning(s)
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
    But i cant figure out what it is, or how to fix it. So if you know, please help me.
    //Ty in advance

  4. #4
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    It tells you there. One of your libs is conflicting with MSVCRT. Normally you have to specify a flag or you can go to your project properties and tell MSVS not to use a certain library. I believe it is under exclude library or something along those lines.

    I had a similar problem using DirectX 9.0c on MSVS 2003. There was a certain library I had to tell it to ignore in order to link.

    You should be linking with MSVCRTD which is the debug version unless you are building in release mode.

  5. #5
    Registered User
    Join Date
    Aug 2007
    Posts
    14
    Ty for the help Bubba.
    But i didnt find the MSVS or MSVCRT lib's, but when i restarted Visual C++, then the same thing happened again, but this time it sad that it was only a warning, so i could run the program anyway... wieard.

    But big thx.

  6. #6
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    It works like this: MS provides several variants of its C runtime library. When zlib and libpng were built, their project settings used one variant, and this was noted in the libraries.

    Your project uses a different variant, but also links against zlib and libpng. The linker wants to use the external libraries' suggestion for the runtime library, but it also sees your project settings. The two conflict, so it warns.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    It doesn't seem to be of much cause for concern:
    I get linker warnings like: "warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library"
    Answer: you are mixing libraries of different types (static vs. dynamic, multithreaded vs. singlethreaded, etc.), but it was only a warning - the project got compiled.
    http://www.bms-austria.com/projects/...c/VisualC.html

    Maybe one of these will help:


    By the way -- there is a library for the SDL that lets you load PNG, JPG, GIF, and many, many more image formats, with alpha support and everything. It probably has a cleaner interface, too. I suggest you have a look at it. It's called SDL_image. http://www.libsdl.org/projects/SDL_image/
    SDL_image is an image file loading library.
    It loads images as SDL surfaces, and supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF, XCF, XPM, XV
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  8. #8
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Well, you will probably get in trouble if, for example, you try to free() a pointer malloc()ed by the library, or vice versa.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #9
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Yes, I guess it depends on how different the various implementations of the standard library are. Anyway, my "doesn't seem to be of much cause for concern" thought was after looking at only a few links. I now think it's probably playing with fire to not do anything about it. The fix looks reasonably simple, too, so that's not much of a problem.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed