由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - How to compile multiple c files into one obj file?
相关主题
调用win32 DLL的问题Questions about MAKEFILE
Question about friend in C++请教如何通过FILE指针删除文件?
各个公司做compiler赚钱吗?How to run existing C files using Visual C++
老年工程师转行学C++的更新的问题*** help needed! on MATLAB GUI ***
Visual C++ Express 很土的问题求救How to tell gcc stop compiling.
C arrayinheritence problem
A C++ compiler related interview questionA tech question (转载)
非虚函数里调用虚函数无效?An interesting C++ compile error
相关话题的讨论汇总
话题: file话题: obj话题: files话题: compile话题: dll
进入Programming版参与讨论
1 (共1页)
g****y
发帖数: 101
1
I have a .c function (including parameter passing) files which will call
multiple other .c and .h files. There is no main function.How can I compile
them into one obj file so that it can be called by other program? Thanks a
lot!
l**t
发帖数: 64
2
Your problem is how to generate the static library,
and it depends on your platform.
for win32, use lib.exe (provided by vc) or ar (for win32)
for linux, use ar (provided by binutils)

compile

【在 g****y 的大作中提到】
: I have a .c function (including parameter passing) files which will call
: multiple other .c and .h files. There is no main function.How can I compile
: them into one obj file so that it can be called by other program? Thanks a
: lot!

g****y
发帖数: 101
3
Thanks!
My platform is win32. My goal is to have an obj file.
There is no main routine, only a c function. How to get an exe file?

【在 l**t 的大作中提到】
: Your problem is how to generate the static library,
: and it depends on your platform.
: for win32, use lib.exe (provided by vc) or ar (for win32)
: for linux, use ar (provided by binutils)
:
: compile

l**t
发帖数: 64
4
you confused me.
If you want to merge many obj files to one file, use the method I previously
told you, and a *.lib file will be generated.
If you want to get a dll file (no main entry, no exe file can be gotten),
use link.exe with the /dll option, which will generate a dll file and lib
file for you.
Of course, you can specify the c function you provided as the new entry
function, by setting the link.exe option /entry as the c function, then the
exe file will be generated and make the c function

【在 g****y 的大作中提到】
: Thanks!
: My platform is win32. My goal is to have an obj file.
: There is no main routine, only a c function. How to get an exe file?

g****y
发帖数: 101
5
lift, Thanks for your kind help!
Here is what my professor wants:
"You sent me 19 separate *.c files, whereas HY-STONE will need only ONE
compiled shared routines to be accessed, containing all the stuff required
to operate (also all the required *.h). The routines must be compiled by
shared routines in order to obtain ONE *.obj files. These will be placed in
the same installation directory as HY-STONE.exe in order to run your
simulations."
It seems difficult to realize in the way he wants. Is i

【在 l**t 的大作中提到】
: you confused me.
: If you want to merge many obj files to one file, use the method I previously
: told you, and a *.lib file will be generated.
: If you want to get a dll file (no main entry, no exe file can be gotten),
: use link.exe with the /dll option, which will generate a dll file and lib
: file for you.
: Of course, you can specify the c function you provided as the new entry
: function, by setting the link.exe option /entry as the c function, then the
: exe file will be generated and make the c function

l**t
发帖数: 64
6
Your boss maybe want to get a dynamic shared library (dll for win32).
As you said that Hy-stone.exe already existed, when it runs, it will load
the
dll file automatically, and call the predefined functions and variables in
the dll file.
Hence, you should know the specification of dll file that HY-STONE.EXE needs
, such as, what functions and variables should be exported, what the name of
dll file is. Then you should provide every functions and variables in you c
or h file.
After that, use "cl *.

【在 g****y 的大作中提到】
: lift, Thanks for your kind help!
: Here is what my professor wants:
: "You sent me 19 separate *.c files, whereas HY-STONE will need only ONE
: compiled shared routines to be accessed, containing all the stuff required
: to operate (also all the required *.h). The routines must be compiled by
: shared routines in order to obtain ONE *.obj files. These will be placed in
: the same installation directory as HY-STONE.exe in order to run your
: simulations."
: It seems difficult to realize in the way he wants. Is i

d*h
发帖数: 2347
7
you compile each of the C files into an OBJ file, then use link/lib tool to
link all OBJ files into single DLL.

compile

【在 g****y 的大作中提到】
: I have a .c function (including parameter passing) files which will call
: multiple other .c and .h files. There is no main function.How can I compile
: them into one obj file so that it can be called by other program? Thanks a
: lot!

1 (共1页)
进入Programming版参与讨论
相关主题
An interesting C++ compile errorVisual C++ Express 很土的问题求救
谁来解释一下这个是compiler问题吗?C array
关于Makefile的一个问题A C++ compiler related interview question
这句话是为什么呢?非虚函数里调用虚函数无效?
调用win32 DLL的问题Questions about MAKEFILE
Question about friend in C++请教如何通过FILE指针删除文件?
各个公司做compiler赚钱吗?How to run existing C files using Visual C++
老年工程师转行学C++的更新的问题*** help needed! on MATLAB GUI ***
相关话题的讨论汇总
话题: file话题: obj话题: files话题: compile话题: dll