Never include .cpp files.
Make a header file (functions.h) and put the function prototypes in the
header file.
Include the header file in the .cpp files that call the functions and in
functions.cpp.
You can also split up your functions.cpp in different files for different
groups of functions, and #include "functions.h" in each of them.
If you want to make a compiled library with your functions you can make a
new static library project and add all the functions files to it.
Compile them and (suppose you called the project you get a .a library file
Now when you want to use the functions you add the library to the project
(Dev-C++ 4.9.7.1: Project-project options-Compiler-Compiler Options-Add
Library or Object)
and include your header file in the .cpp files that use the functions.
If you want to use the functions in several projects this is better. If the
functions are in a library (.a) file only the functions that are used are
put into the .exe file.
It is also possible to use the archiver to make library files that are
automaticly found by the linker, like many library files in the .lib
directory. I never did that, so I can´t tell you about it.
Wobien
----- Original Message -----
From: <bal...@cf...>
To: <dev...@li...>
Sent: Saturday, February 08, 2003 4:29 PM
Subject: [Dev-C++] Including Function From Other .cpp files
> I am converting some code from various other programming languages into
C++.
> However, I really want to build a library of functions within various C++
> files. However, I am not certain how to call functions from different cpp
> files.
>
> I assume include the .cpp file. However, do I put the function prototype
in
> the code calling the function or leave everything in my functions.cpp
file?
>
> Any help, advise and pointers would be greatly appreciated...
>
> Thanks..
>
>
>
>
>
> -------------------------------------------------------
> This SF.NET email is sponsored by:
> SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
> http://www.vasoftware.com
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|