Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include .obj files into the project

Tags:

c++

I have the following question: I was given the task - to build an application. There was a ready file counter.h and some other file - counter.obj. It turned out that in the counter.h there were only declarations of the functions - how can I include .obj file into the .cpp file so that it compiles? I am using Microsoft Visual Studio 2010 - and in which folder should the file itself go?

like image 284
Artem Moskalev Avatar asked Oct 30 '11 17:10

Artem Moskalev


People also ask

What software opens OBJ format?

Files in OBJ format can be opened with Autodesk Maya 2013, Blender, and MeshLab in Microsoft Windows, Mac OS, and Linux platforms.

What are .OBJ files in Visual Studio?

Object files contain relocatable machine code that is generated from your source code. Visual Studio creates one . obj file per each .

What is .OBJ file in assembly language?

8.3. The assembler is used to convert an assembly file into an object file (. obj extension). The assembly optimizer and the compiler are used to convert, respectively, a linear assembly file and a C file into an object file. The linker is used to combine object files, as instructed by the linker command file (.

How do I open a OBJ file in Windows?

Just install the software OBJ Viewer To begin viewing 3D files, simply do the following Install the extension OBJ Viewer Click on the extension icon Choose the 3D file you wish to open Begin viewing your 3D files online today! This 3D viewer works for both STL and OBJ file formats.


2 Answers

Add the obj-file to the Solution just as you would do with cpp-files (i usually do this by drag-and-drop, that is, drag the file from the Windows Explorer and drop it on a project in the Solution Exporer window).

You can put the obj-file together with cpp-files; it doesn't really matter.

like image 68
anatolyg Avatar answered Oct 16 '22 10:10

anatolyg


You do cannot include object file in to a cpp file.
The compiler compiles the cpp file and generates the obj files, for each cpp file, these files are further linked together to create an libray or an executable.

Usually, you would link libraries(.lib or .dll) to an Application, Check if those are with you.

If not,

You can try linking the object file to your application by:
Go to project properties then from "Property Page" select the node "C/C++" their you will get "Additional Include Directories" add the name of your object file.Keep your obj file in the directory where your source code is or you can add the directory from:
Tools->Options->Projects and Solutions->VC++Directories.

I have never tried the second method except for academic projects,which was years ago, So not sure about it, Please check information on MSDN.

like image 39
Alok Save Avatar answered Oct 16 '22 11:10

Alok Save