Making VC++ create only one object file?
-
Hello everyone! I gave up trying to convert my CPP files to CPP/H files... The problem is this. I regularly use GCC for C++ coding, but I'm on Vista and that compiler doesn't work correctly on it. So I'll use Visual Studio instead. But Visual Studio seems to compile each CPP file into its own object file and then link them all together, so I get a lot of undefined references... Is there any way to just compile index.cpp (my main file, where all other CPP files are called from)? Thanks!
Windows Calculator told me I will die at 28. :(
-
Hello everyone! I gave up trying to convert my CPP files to CPP/H files... The problem is this. I regularly use GCC for C++ coding, but I'm on Vista and that compiler doesn't work correctly on it. So I'll use Visual Studio instead. But Visual Studio seems to compile each CPP file into its own object file and then link them all together, so I get a lot of undefined references... Is there any way to just compile index.cpp (my main file, where all other CPP files are called from)? Thanks!
Windows Calculator told me I will die at 28. :(
It's not really an answer to your question, as I don't know how to do it, but you might give a try in the compiler / linker options. Might be able to customize the build rules for your project. Anyways, shouldn't you have used .h files in the first place :)? They do serve a purpose :P
-
Hello everyone! I gave up trying to convert my CPP files to CPP/H files... The problem is this. I regularly use GCC for C++ coding, but I'm on Vista and that compiler doesn't work correctly on it. So I'll use Visual Studio instead. But Visual Studio seems to compile each CPP file into its own object file and then link them all together, so I get a lot of undefined references... Is there any way to just compile index.cpp (my main file, where all other CPP files are called from)? Thanks!
Windows Calculator told me I will die at 28. :(
Lord Kixdemp wrote:
But Visual Studio seems to compile each CPP file into its own object file
That is normal (for every compiler I’ve used), as each file represents a separate unit. Undefined references are a different problem all together. If you want a single object file, then use the #include syntax to include all the ‘.cpp’ files in a file called “index.cpp” and then only include that file in the project. Of course this is not normal and you may not have enough memory to do it, but it should work.
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
-
Lord Kixdemp wrote:
But Visual Studio seems to compile each CPP file into its own object file
That is normal (for every compiler I’ve used), as each file represents a separate unit. Undefined references are a different problem all together. If you want a single object file, then use the #include syntax to include all the ‘.cpp’ files in a file called “index.cpp” and then only include that file in the project. Of course this is not normal and you may not have enough memory to do it, but it should work.
INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
OK, since everyone seems to be against not using header files, I gave it another try. This time it worked. Thanks everyone! ;)
Windows Calculator told me I will die at 28. :(