Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Making VC++ create only one object file?

Making VC++ create only one object file?

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpdatabasevisual-studio
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lord Kixdemp
    wrote on last edited by
    #1

    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. :(

    M J 2 Replies Last reply
    0
    • L Lord Kixdemp

      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. :(

      M Offline
      M Offline
      Michael Sadlon
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • L Lord Kixdemp

        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. :(

        J Offline
        J Offline
        John R Shaw
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • J John R Shaw

          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

          L Offline
          L Offline
          Lord Kixdemp
          wrote on last edited by
          #4

          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. :(

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups