How to include .obj files into the project

前端 未结 2 1214
难免孤独
难免孤独 2020-12-16 22:39

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

相关标签:
2条回答
  • 2020-12-16 23:05

    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.

    0 讨论(0)
  • 2020-12-16 23:16

    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.

    0 讨论(0)
提交回复
热议问题