How to Link OBJ Files in Turbo C++


The classic Turbo C++ compiler can be used as either an integrated development environment or a command-line tool. While compiling and running a program from within the Turbo C++ editor will both generate object files and link them automatically, you can do it manually one step at a time at the command line. The command "tcc /c file1.cpp" will create an unlinked .obj file out of your code, allowing you to link it later yourself.

  • Open Command Prompt, found under "Accessories" in the Start menu. (The "Start" menu is the Windows-logo button on the lower-left-hand corner of the screen).

  • Change the current directory to that which contains your .obj files using the "cd" command. If the files are in a folder named Programming under My Documents and your name is Philippe, then this would look like the following:

    cd C:\Users\Philippe\Documents\Programming

  • Run the Turbo C++ linker using the "tlink" command. This command takes the .obj filenames, the desired .exe filename, the desired .map filename and any .lib filenames as arguments, separated by commas. Multiple files are combined with pluses and any type of file unused can be left out. If you have two .obj files and use no external libraries in your code, the command could look like this:

    tlink file1.obj + file2.obj, hello.exe

    If you use the standard libraries, however, you must include them manually. Assuming Turbo C++ is installed under C:\TC, a program with one .obj file that uses the standard libraries would be linked like this:

    tlink \TC\LIB\C0S.obj + file.obj, hello.exe, , \TC\LIB\CS.lib

Related Searches


Promoted By Zergnet



Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!