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!
Printable View
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!
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.
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!
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.
You can add them to your project just as if they were a .cpp file.
Thank you anyways:)
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.
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?
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::operator=(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
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
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
Woops, just saw your post GCDEF. I will give it a shot now. Thanks!
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!
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.....
[ merged threads ]
Please do not start multiple threads on the same problem.
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
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
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!
Depends on whether there's a main() function somewhere in his code.
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.
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!
WHERE is int main(...) {...} implemented???Quote:
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
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;}
Okay, here is my main.cpp:
#include "AbstractActions.h"
#include "AbstractInterfaceDefinition.h"
#include "AICharacters.h"
#include "BasicCharacter.h"
#include "BasicObjects.h"
#include "DialogPathMapping.h"
#include "Functions.h"
#include "GoalsAndFeelings.h"
//#include "Help.h"
#include "HighScores.h"
#include "InfoToVEClasses.h"
#include "InitialInteractiveActions.h"
#include "IntentionalAgent.h"
#include "Items.h"
#include "OtherCharacterModel.h"
#include "PlayerCharacter.h"
#include "ReactiveActions.h"
#include "ResponseActions.h"
#include "SoloActions.h"
#include "WEConcreteInterfaceDefinition.h"
int main()
{
return 1;
}
O, btw, not sure I state it clearly. The BuildLog is what he sent me, not mine. His code does not have a main I think, which is why it has the link error. Because he's sending me the interface that he wants me to implement my own main() and do testing.
Thanks!