Linking Headers and Source
I am using VS2005 development environment.
I have an existing source code which takes a lot of header files as well as source and library files
Code:
D:\..\SRC\C++\MyProject\srclib
All the include and source files lies within the sub folder of this folder
Include file directories
Code:
D:\..\SRC\C++\MyProject\srclib\apr\include
D:\..\SRC\C++\MyProject\srclib\apr-iconv\include
D:\..\SRC\C++\MyProject\srclib\apr-util\include
Similarly there are library files as well as source files that reside within this scrlib too.
Now the problem is specifying the path of these folders so that the compiler is able to find the header files therefore the function signature
Now one way is to include these directories in "Tools>Options>Project & Solution>VC++ Directories".
Or we go to "project settings and in General>C/C++>additional Include Directories", specify the settings.
I choosed the 2nd option for include directory.
Code:
./include
./srclib/apr/include
./srclib/apr-util/include
./srclib/apr/memory/unix
But the problem that I am facing can be demonstrated with this example.
"apr_pools.h" contains some important function signatures reside in this location
Code:
D:\..\SRC\C++\MyProject\srclib\apr\include
However its corresponding source file "apr_pools.c" which contains the implementation of those functions reside in this location
Code:
D:\..\SRC\C++\MyProject\srclib\apr\momory\unix
I included this path using "Tools>Options>Project & Solution>VC++ Directories>" and in show directories selected Souce File
But compiler is unable to find the implementation of the methods that are in apr_pool.h thus generates external unresolved symbol error
Is there any neat and efficient way of including directories when there are too many complex paths?
Thanks & Regards,
Adeel
Re: Linking Headers and Source
we have two Scenario , if your header files have CPP or C files with them then you are placing them wrong area , they not to be included in project include options , they need to be placed in the project file in the left of your project settings, so go to the project folder on the left , and select add existing , header for header folder and sources for sources folder.
the other option , is header files are accompanied by lib files , then you have selected the right choice , in the include options , all you need to do now is to tell the compiler where the lib files are , since I have not used vs 2005 in a while you can look it up on the web , setting are pretty straight forward.
Finally when you get unresolved symbols errors , that means linker cannot find the implementations of the function in your header files , cause by default header files only contain the declaration of the functions and data types .
hope this helps.
Re: Linking Headers and Source
Quote:
Originally Posted by
aamir121a
we have two Scenario , if your header files have CPP or C files with them then you are placing them wrong area , they not to be included in project include options , they need to be placed in the project file in the left of your project settings, so go to the project folder on the left , and select add existing , header for header folder and sources for sources folder.
the other option , is header files are accompanied by lib files , then you have selected the right choice , in the include options , all you need to do now is to tell the compiler where the lib files are , since I have not used vs 2005 in a while you can look it up on the web , setting are pretty straight forward.
Finally when you get unresolved symbols errors , that means linker cannot find the implementations of the function in your header files , cause by default header files only contain the declaration of the functions and data types .
hope this helps.
yes some header files have their implementation on .c file and some project files have their implementation in .lib files. But this is default settings for these Apache SDKs.
Now "apr_pool.h" resides in this location which contains the signature
Code:
D:\..\SRC\C++\MyProject\srclib\apr\include
And its corresponding source file "apr_pools.c" which contains the implementation of those functions reside in this location
Code:
D:\..\SRC\C++\MyProject\srclib\apr\momory\unix
Whre is that project file option that you are talking about?
Re: Linking Headers and Source
./include
./srclib/apr/include
./srclib/apr-util/include
./srclib/apr/memory/unix
in windows we used \ for paths instead / so it should be
.\include
.\srclib\apr\include
.\srclib\apr-util\include
.\srclib\apr\memory\unix
Re: Linking Headers and Source
Quote:
Originally Posted by
hypheni
./include
./srclib/apr/include
./srclib/apr-util/include
./srclib/apr/memory/unix
in windows we used \ for paths instead / so it should be
.\include
.\srclib\apr\include
.\srclib\apr-util\include
.\srclib\apr\memory\unix
Changed it. Still the result is same :(
Re: Linking Headers and Source
I've tried everything. But the compiler is unable to find the implementation of functions residing this header file.
Code:
D:\..\SRC\C++\MyProject\srclib\apr\include\apr_pool.h
Though their implemenration is available in in this header file
Code:
D:\..\SRC\C++\MyProject\srclib\apr\momory\unix\apr_pool.c
Re: Linking Headers and Source
There's always the doomsday option for including headers:
Code:
#include "D:\theComplete\directory\structure\SRC\C++\MyProject\srclib\apr\include\apr_pool.h"
Quote:
But the compiler is unable to find the implementation of functions residing this header file.
So you're saying that the implementation (not the definition that usually lives in the header file, but that actual source code that carries out the operations) can't be found? If the implementation exists in a source file (rather than an already compiled library), then your problem is that you're not compiling that source and linking to it. As I recall, under VS there's some kind of "add this source file to the project" option that covers that.
1 Attachment(s)
Re: Linking Headers and Source
this one is for the source file only header with , C or CPP files , place all header and C / CPP files in the same folder , open up the C file in text editor ( not vc) and make sure that include file in those C files is <myheader.h> only and not <path/myhader.h> , then go to all header files and change all include to <myheader.h> and not <path/myheader.h> . now add them through the method I explained , when you are changing the header include path , only change for those which came with the sources , and not the header which are windows default , like iostream or windows.h
please see attached screen shot as to where to add the header and source file , better still if you like send me the project you are compiling , and I will set it up for you.
some times the referencing paths inside a C or a header file , do not match
I have see this a lot in open source project , wxWidgets , or zlib
you can upload your zip file of the project through
http://www.sendspace.com
and post the download link here. PM me the link
Re: Linking Headers and Source
Quote:
Originally Posted by
maverick786us
I've tried everything. But the compiler is unable to find the implementation of functions residing this header file.
Code:
D:\..\SRC\C++\MyProject\srclib\apr\include\apr_pool.h
Though their implemenration is available in in this header file
Code:
D:\..\SRC\C++\MyProject\srclib\apr\momory\unix\apr_pool.c
from the path , look like apr_pool.h and apr_pool.c are not in the same directory pls . make sure the apr_pool.c include directives are referencing the apr_pool.h properly
, further looks like may be compiling a unix version , in that case ( VS 2005 ) or any other VS does not support unix header , please make sure that is not the case. you might need cgywin and mingw to compile this , but that is another story.
Re: Linking Headers and Source
here in the link on how to compile apache SDK for win32
http://httpd.apache.org/docs/1.3/win_compiling.html