Results 1 to 13 of 13

Thread: Linker errors [Resolved]

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Linker errors [Resolved]

    Hello again all.

    Linker trouble this time. When i try to compile i get the following error:

    TerrainGen error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
    TerrainGen error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(dbgdel.obj)
    I havn't tried to override the new or delete operators or anything (i don't even use them). I am using 3 files in my C++ .Net 2003 project with header includes as shown:

    Code:
    Bitmap.h
    #include <stdio.h>
    #include <malloc.h>
    #include <windows.h>
    
    Main.cpp
    #include <afxwin.h>
    #include <windows.h>
    #include <d3dx9.h>
    
    Direct3D.cpp
    #include "Bitmap.h"
    #include <mmsystem.h>
    #include <d3dx9.h>
    Any ideas on what can be causing the error? I've fiddled around with the includes but can't seem to get the project to compile (either with error: indefined messages, or errors as above).

    Thanks for any help provided.
    Last edited by SLH; Dec 23rd, 2003 at 12:36 PM.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  2. #2
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Are you using those

    #ifndef
    #define

    #endif

    I can see you have added windows.h two places...

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Seems like an import library that conflicts with the Standard C++ Library. That's always fun.

    Try to use the "ignore default library" field in the linker options. Try ignoring libcmtd.lib and see what happens.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Thanks both of you for the replys.

    NoteMe: I'm not using those preprocessing contitionals and i don't think i need to because although windows.h is included twice it never gets put in a cpp file twice. Correct me if i'm wrong.

    CornedBee:I tried that but i get lots (100) of unresolved externals. Not sure what you meen by an import libary, but i don't think i'm importing any that would cause a conflict (i'm only using the standard libarys and the DX9 ones).

    I looked at the build output (when it tried to compile) again and saw this:

    nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z) already defined in LIBCMTD.lib(new.obj)
    nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) already defined in LIBCMTD.lib(db
    gdel.obj)

    Thinking that nafxcwd.lib could be the problem i excluded that but i had a few unresolved external errors so i don't think that's the problem. Any other ideas?
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  5. #5
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by SLH
    Thanks both of you for the replys.

    NoteMe: I'm not using those preprocessing contitionals and i don't think i need to because although windows.h is included twice it never gets put in a cpp file twice. Correct me if i'm wrong.

    You are right. I wasn't thinking straight....of course you are not the one too put that in the windows.h file....but I think it is a nice thing to do in all h files that you are making. It can be pretty bad linking errors if you don't...

  6. #6

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Yeah, it confused the hell out of me the first time i got that type of error. Not immediatly obvious when it's caused by header files including other header files etc...
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You never get linking errors from failing to have double inclusion guards, only compile errors.

    nafxcwd.lib
    what is this library?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I have had linking error in GCC when I didn't use ifndef. But that might have been a bug. At least the problem solved when I added it...

  9. #9

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Cheers for the replys
    Originally posted by CornedBee
    nafxcwd.lib
    what is this library?
    I have no idea the only custom libs i use are the DX9 ones. I can only assume that the header afxwin.h uses it.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Why do you use MFC then?

    Maybe linking to MFC dynamically would help.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    As far as i'm aware i'm not using MFC, at least in project options 'Use of MFC' is set to 'Use Windows Standard Librarys', or do you meen that somewhere i'm trying to use an MFC library, but am not including it (or something)?

    Unless DX9 uses MFC the only other place that could use it is in my bitmap header file that i got from planetsourcecode but it doesn't say anything about using MFC.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    If you include afxwin.h then you're using MFC, it's an MFC header.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Oh, ok thanks. I've managed to fix the problem. I think it was as CornedBee suggested, MFC troubles. I managed to figure a way of not using afxwin.h and now it works (well, compiles and runs).

    Thanks again for your help.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width