Board index » cppbuilder » Including object files in a project

Including object files in a project


2004-01-04 07:44:34 AM
cppbuilder90
Hi all,
I'm afraid that I have a kind of a 'newbie' question, but I cannot find the
answer in either C++ builder documentation or the internet.
The problem is as follows, I have created progam that includes different
source files. One of these source files includes other source files. (F.E.
include1.h includes partA.h and partB.h)
In a new project I want to use include1.h again by adding is include1.obj to
the project.
Compiling will cause errors of the type [Linker Error] Unresolved external
'X' referenced from 'include1.obj'.
So now I'm forced to include both partA.obj and partB.obj files into the
project file. AND I DO NOT WANT THIS. I just want to refer to the 'parent'
file. (in this case include1.h)
How do you normally handle multiple files which you want to share between
projects? Creating a DLL or package might be a little over the top here.
Hope one of you can help me out,
Thanks in advance.
Oscar
 
 

Re:Including object files in a project

oscar(at)safekimono(dot)nl wrote:
Quote
The problem is as follows, I have created progam that includes different
source files. One of these source files includes other source files. (F.E.
include1.h includes partA.h and partB.h)
That are not sourcefiles I would say. h files are header files.
Quote
In a new project I want to use include1.h again by adding is include1.obj to
the project.
Again that is a misconception. h files do not cause for obj files.
You will only get an obj file if you compile a c/cpp file.
You will have to make a cpp file like include1.cpp that includes
partA.cpp and partB.cpp.
Hans.
 

Re:Including object files in a project

Quote
You will have to make a cpp file like include1.cpp that includes
partA.cpp and partB.cpp.

I know but sorry, this is not the question. Maybe I am unclear, but I
find it hard to describe the problem. I am always using the builder
interface, so i dont have to worry about linking or makefiles.
I just want to add the compiled source (include1.obj) to a project and
dont want to add its dependencies (partA.obj, partB.obj).
Its very annoying when I add a new dependency to include1 (f.e. partC)
and have to add (partC.obj) to each project which uses include1.obj.
Oscar
 

{smallsort}

Re:Including object files in a project

On Sun, 04 Jan 2004 21:38:43 +0100, Oscar van den Bosch wrote:
Quote
I just want to add the compiled source (include1.obj) to a project and
dont want to add its dependencies (partA.obj, partB.obj).
But it /is/ dependent on partA and partB.
To do what you'd like you'll have to remove the parts of include1 which
are unrelated to partA and partB and create a separate obj.
--
liz
 

Re:Including object files in a project

"Hans Galema" < XXXX@XXXXX.COM >schrieb im Newsbeitrag
Quote
oscar(at)safekimono(dot)nl wrote:

>The problem is as follows, I have created progam that includes different
>source files. One of these source files includes other source files.
(F.E.
>include1.h includes partA.h and partB.h)

That are not sourcefiles I would say. h files are header files.

>In a new project I want to use include1.h again by adding is
include1.obj to
>the project.

Again that is a misconception. h files do not cause for obj files.
You will only get an obj file if you compile a c/cpp file.

You will have to make a cpp file like include1.cpp that includes
partA.cpp and partB.cpp.

Hans.
And at the end, if you want to use this code serveral times you should
create a library file ( start with a static one). And than you add this lib
file to your project.
Detlef