build a project using given obj files - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 33

Thread: build a project using given obj files

  1. #16
    Join Date
    Sep 2008
    Posts
    21

    Re: link external obj files in vs 2005

    Woops, just saw your post GCDEF. I will give it a shot now. Thanks!

  2. #17
    Join Date
    Sep 2008
    Posts
    21

    Re: link external obj files in vs 2005

    Quote Originally Posted by GCDEF View Post
    In your project settings, add LIBCMT to the Ignore Specific Library section of your linker input options.

    Looks like there's some kind of function call Xran that the linker doesn't know about. Did you add all the files you're supposed to?
    I typed LIBCMT in the field of "Ignore Specific Library" under Linker->Input...hope im doing right.

    There are all together 62 errors. About 20 of them are complaining Xran function and 20 of them complains about Xlen like this:
    Error 28 error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xlen(void)const " (?_Xlen@_String_base@std@@QBEXXZ) TickCharacters.obj
    and the rest are like this:
    Error 57 error LNK2001: unresolved external symbol "public: void __thiscall std::ios_base::_Addstd(void)" (?_Addstd@ios_base@std@@QAEXXZ) NewGame.obj

    I think I included all the obj files. Together with the obj files they also gave me several cpp and h files. Initially I tried adding them and build, which gave me lots of compile errors so I decided starting from a simple main(). I checked with those cpp/h files and none of them contains the functions the linking errors are complaining about...

    Many thanks!

  3. #18
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: link external obj files in vs 2005

    Looks like (definately not enough information to be sure) the provided obj files are built against a different implementation (or build configuration) of the STL library.....
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  4. #19
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    Re: build a project using given obj files

    [ merged threads ]

    Please do not start multiple threads on the same problem.

  5. #20
    Join Date
    Apr 1999
    Posts
    27,427

    Re: link external obj files in vs 2005

    Quote Originally Posted by GCDEF View Post
    Read the errors again. They're unresolved external and already defined errors.
    I gave a general reason of why errors would show up when linking object files, and what to make sure of before going on any further.

    Regardless of what the resolution is, the options used to create the object files must be known by the person using them, so as to minimize any problems.

    Regards,

    Paul McKenzie

  6. #21
    Join Date
    Sep 2008
    Posts
    21

    Re: build a project using given obj files

    Thanks folks,
    I just got back from the guy who gave me the obj files. He said he's gonna create a clean system and build again with only the cpp/h files he gave me in the folder and send me again. So this time hopefully it'll work T.T...waiting on him now

  7. #22
    Join Date
    Apr 1999
    Posts
    27,427

    Re: build a project using given obj files

    Quote Originally Posted by lqakane View Post
    Thanks folks,
    I just got back from the guy who gave me the obj files. He said he's gonna create a clean system and build again with only the cpp/h files he gave me in the folder and send me again. So this time hopefully it'll work T.T...waiting on him now
    Again, it's not just the CPP and H files that are the concern.

    He needs to tell you what options he is using to build the object files. Library options, debug/release, etc. He could be even using a different version of the compiler (service pack) than what you're using. All of these things are to be known on both ends for a successful link to occur.

    Regards,

    Paul McKenzie

  8. #23
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: build a project using given obj files

    If they are buildable from the CPP/H files that he gave you....why are you complicating things by using his .boj files??????

    Just compile the source yourself...

    Of course it is likely that they are actually NOT going to be built "with only the cpp/h files he gave me in the folder"
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  9. #24
    Join Date
    Sep 2008
    Posts
    21

    Re: build a project using given obj files

    Quote Originally Posted by TheCPUWizard View Post
    If they are buildable from the CPP/H files that he gave you....why are you complicating things by using his .boj files??????

    Just compile the source yourself...

    Of course it is likely that they are actually NOT going to be built "with only the cpp/h files he gave me in the folder"
    Sry my bad...you are right. I think this time he's gonna give me all the obj files and part of the source files that he's allowed to give, and the system config files (as Paul suggests, the config files probably have the information of the compiler versions, lib info, etc. I assume?).
    Still waiting on him. When getting the new obj files, and configure correctly, do I actually need to add any of my own code (like main() ) to test or it should run with only the obj files?
    Thanks a lot!

  10. #25
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    Re: build a project using given obj files

    Depends on whether there's a main() function somewhere in his code.

  11. #26
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,090

    Re: build a project using given obj files

    Quote Originally Posted by Paul McKenzie View Post
    Again, it's not just the CPP and H files that are the concern.

    He needs to tell you what options he is using to build the object files. Library options, debug/release, etc. He could be even using a different version of the compiler (service pack) than what you're using. All of these things are to be known on both ends for a successful link to occur.

    Regards,

    Paul McKenzie
    I've got obj files from a vendor. No clue what they used to build them. They're release builds but they work fine in both release and debug builds and on VC6 and VS2005. So while issue may potentially arise, using the same service pack, build type, even compiler version isn't a requirement.

  12. #27
    Join Date
    Sep 2008
    Posts
    21

    Re: build a project using given obj files

    Hey guys,
    So I got back from him. He gave me all the obj files, all headers, and buildLog(which I think gives the compiler configuration). He said I should be able to compile except there is one link error right now which he believes caused by lack of toplevel entry point (no main function i guess?).

    So what I did was: wrote a main function, include all headers, added all the obj files to the project. Surprisingly there's no linking errors, but 6 compile errors....saying there is no definition of some class:
    Error 12 error C2236: unexpected 'class' 'StubVisualCommands'. Did you forget a ';'? c:\documents and settings\sandy\my documents\supple\supplecode\trialtwo\trial two\trial two\weconcreteinterfacedefinition.h 8
    (this class is inherited from some other class which was obviously defined)
    I commented out the whole class definition. This time several other compiling errors pop up...I kept commenting out stuffs and realized it should not be the right way. So my question is, can it possible because of compiler compatibility? I linked all obj files successfully this time and they are not complaining anything. In that case if it compiles on his machine it should also compile on mine. Anyone has any clue? Here is the BuildLog...Im not sure how to use it. Mine is a Win32 Console project btw...

    Build Log


    ------- Build started: Project: WorldEngine, Configuration: Release|Win32 -------

    Command Lines


    This edition of Visual C++ does not support the optimizing compiler.
    This edition of Visual C++ does not support the optimizing compiler.
    Creating temporary file "c:\Supple\WorldEngine\Release\RSP000001.rsp" with contents
    [
    /AI "C:\Supple\WorldEngine\Release" /D "WIN32" /D "NDEBUG" /D "_MBCS" /FD /EHsc /MT /GS /Fo"Release/" /Fd"Release/vc70.pdb" /W0 /c /Zi /clr /TP
    .\BehaviorEngine.cpp
    ]
    Creating command line "cl.exe @c:\Supple\WorldEngine\Release\RSP000001.rsp /nologo"
    Creating temporary file "c:\Supple\WorldEngine\Release\RSP000002.rsp" with contents
    [
    /OUT:"C:\Supple\WorldEngine\Release\WorldEngine.exe" /INCREMENTAL:NO /NOLOGO /DEBUG /PDB:"C:\Supple\WorldEngine\Release/WorldEngine.pdb" /FIXED:No kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
    .\Release\ActionDescriptions.obj
    .\Release\BehaviorEngine.obj
    ......

    Output Window


    Compiling...
    BehaviorEngine.cpp
    Linking...
    LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
    C:\Supple\WorldEngine\Release\WorldEngine.exe : fatal error LNK1120: 1 unresolved externals

    Results


    Build log was saved at "file://c:\Supple\WorldEngine\Release\BuildLog.htm"
    WorldEngine - 2 error(s), 0 warning(s)


    Thank you so much!

  13. #28
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: build a project using given obj files

    LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
    WHERE is int main(...) {...} implemented???
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  14. #29
    Join Date
    Sep 2008
    Posts
    21

    Re: build a project using given obj files

    Quote Originally Posted by TheCPUWizard View Post
    WHERE is int main(...) {...} implemented???
    I think he did not write a main function when generating the obj files. The reason is through the interface he gave me I should write my own main to do testing. If he did write a main, I would not be able to test as a program cannot have two mains. Am I right?
    I wrote my own main.cpp which includes all header files. In this cpp I wrote int main() { return 1;}

  15. #30
    Join Date
    Mar 2002
    Location
    NY, USA
    Posts
    12,097

    Re: build a project using given obj files

    Quote Originally Posted by lqakane View Post
    I think he did not write a main function when generating the obj files. The reason is through the interface he gave me I should write my own main to do testing. If he did write a main, I would not be able to test as a program cannot have two mains. Am I right?
    I wrote my own main.cpp which includes all header files. In this cpp I wrote int main() { return 1;}
    You may think you did...but...the linker is not seeing it.

    Most likely, you did not include the file in the linker command, possibly you declared main as having file scope, maybe you even spelled main wrong. Please SHOW your implementation of main.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009
    In theory, there is no difference between theory and paractice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

Page 2 of 3 FirstFirst 123 LastLast

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center