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

Thread: build a project using given obj files

  1. #1
    Join Date
    Sep 2008
    Posts
    21

    build a project using given obj files

    Hello guys,
    Sorry it might sounds silly, but how can I build a solution using given obj files and several cpp files in vs2005?
    Thank you so much!

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,567

    Re: build a project using given obj files

    Hi!

    Create a new solution/project and the add all the existing cpp files to it.

    Obj files are intermediate files generated during compilation. You do not need those.
    Nobody cares how it works as long as it works

  3. #3
    Join Date
    Sep 2008
    Posts
    21

    Re: build a project using given obj files

    Thank you for your response. The thing is, im building a project and part of the code is hidden. I was only given some of the obj files and im supposed to link those in my solution.....not sure how to do that since never did that before :-|

    Tried doing that in properties dialog, but no luck. Any help will be much appreciated.

    Thanks again!

  4. #4
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,567

    Re: build a project using given obj files

    I see.

    Never done this, but if you go into your project settings and look in the "Link" section there is a field where you can enter "Object/library modules".

    The common use of this field is to enter the .lib files, but .obj files might work as well. Give it a try.
    Nobody cares how it works as long as it works

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    11,979

    Re: build a project using given obj files

    You can add them to your project just as if they were a .cpp file.

  6. #6
    Join Date
    Sep 2008
    Posts
    21

    Re: build a project using given obj files

    Thank you anyways

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    11,979

    Re: build a project using given obj files

    Quote Originally Posted by lqakane View Post
    Thank you anyways
    Is your question not answered?

  8. #8
    Join Date
    Sep 2008
    Posts
    21

    link external obj files in vs 2005

    Dear everyone:
    I asked a similar question here yesterday. So basically I am trying to link some given obj files as if they are static libraries. For example if I have action.obj somewhere, I right click on the project name and chose "add->existing item" and simply added action.obj file under the project. It's not compiling....so im wondering if i should do anything in my header files like #include<action.obj>, but im not sure how to do that...any one has any thoughts?
    Thank you soooo much.

  9. #9
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    11,979

    Re: link external obj files in vs 2005

    What do you mean "it's not compiling". I told you in your other thread (which you should have bumped instead of starting another thread) that just adding them to the project should be all you need. I have several projects that work that way and compile fine.

    What is the problem specifically and what error messages are you getting?

  10. #10
    Join Date
    Sep 2008
    Posts
    21

    Re: link external obj files in vs 2005

    Thanks GCDEF, I did follow what you said yesterday and added them as if they are cpp files. I could not find my old thread today so just started a new one, sorry that im new here.
    Basically after adding those obj files, I only made a main function like this, to test if those obj files are linked:
    int main()
    {
    return 1;
    }
    When adding the obj files, they did asked me saying the building rules are not defined. I just hit cancel as I was not sure what to do there -_-
    Here are some of the error messages I got:
    Once again thanks for your help and sorry was messing up the threads earlier.

    Error 1 error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj) MSVCRTD.lib
    Error 2 error LNK2005: "private: class type_info & __thiscall type_info:perator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj) MSVCRTD.lib
    Error 4 error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) TickCharacters.obj
    Error 5 error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) UpdateCharacters.obj
    Error 6 error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) work.obj

  11. #11
    Join Date
    Apr 1999
    Posts
    27,418

    Re: link external obj files in vs 2005

    Quote Originally Posted by lqakane View Post
    When adding the obj files, they did asked me saying the building rules are not defined. I just hit cancel as I was not sure what to do there -_-
    Here are some of the error messages I got:
    Let's start from step 1.

    First, an object file is an intermediate file created by the compiler. Given that, these object files were created using certain compiler options, i.e. debug, release, optimizations, etc.

    This means that you can't just "drop-in" object files into a project without full information on how those object files were compiled.

    What compiler was used to compile these object files? What version of the compiler was used? What compiler options? Were these object files created using the static or DLL version of the runtime? etc. etc.

    Whatever those answers are, that is what your main application must be compiled with. Otherwise, you're taking object files created one way, and trying to apply it to an application created another way. That, in general, is what those errors are telling you.

    Regards,

    Paul McKenzie

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

    Re: link external obj files in vs 2005

    Quote Originally Posted by Paul McKenzie View Post
    Let's start from step 1.

    First, an object file is an intermediate file created by the compiler. Given that, these object files were created using certain compiler options, i.e. debug, release, optimizations, etc.

    This means that you can't just "drop-in" object files into a project without full information on how those object files were compiled.

    What compiler was used to compile these object files? What version of the compiler was used? What compiler options? Were these object files created using the static or DLL version of the runtime? etc. etc.

    Whatever those answers are, that is what your main application must be compiled with. Otherwise, you're taking object files created one way, and trying to apply it to an application created another way. That, in general, is what those errors are telling you.

    Regards,

    Paul McKenzie
    Read the errors again. They're unresolved external and already defined errors.

  13. #13
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    11,979

    Re: link external obj files in vs 2005

    Quote Originally Posted by lqakane View Post
    Thanks GCDEF, I did follow what you said yesterday and added them as if they are cpp files. I could not find my old thread today so just started a new one, sorry that im new here.
    Basically after adding those obj files, I only made a main function like this, to test if those obj files are linked:
    int main()
    {
    return 1;
    }
    When adding the obj files, they did asked me saying the building rules are not defined. I just hit cancel as I was not sure what to do there -_-
    Here are some of the error messages I got:
    Once again thanks for your help and sorry was messing up the threads earlier.

    Error 1 error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj) MSVCRTD.lib
    Error 2 error LNK2005: "private: class type_info & __thiscall type_info:perator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMT.lib(typinfo.obj) MSVCRTD.lib
    Error 4 error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) TickCharacters.obj
    Error 5 error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) UpdateCharacters.obj
    Error 6 error LNK2001: unresolved external symbol "public: void __thiscall std::_String_base::_Xran(void)const " (?_Xran@_String_base@std@@QBEXXZ) work.obj
    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?

  14. #14
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    11,979

    Re: link external obj files in vs 2005

    Quote Originally Posted by lqakane View Post
    I could not find my old thread
    http://www.codeguru.com/forum/showthread.php?t=468392

  15. #15
    Join Date
    Sep 2008
    Posts
    21

    Re: link external obj files in vs 2005

    Thank you so much Paul^^
    Hmm, I only know roughly how compiler works. Given this situation, I guess I do not have any other options besides asking the person who gave me those obj files what compiler he used. Am I right?
    Once I got his answer, I might have to consult you here again if it still does not compile. Hope you don't mind. Best regards and have a nice morning.
    Sandy

Page 1 of 3 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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center