作者:非船_725 | 来源:互联网 | 2023-01-31 18:56
IamtryingtowriteaprogramthatwillplayagameusingstrategiesthatIcaneasilymodifyandc
I am trying to write a program that will play a game using strategies that I can easily modify and compile in multiple directories. Most of the source files of the game are immutable (i.e. they remain the same even when strategies are altered). Say my source files are a.c, b.c, c.c, d.c, e.c
, where a.c
through d.c
are immutable and e.c
is the only file that varies between different strategies. In addition, a.c
makes a call to e.c
, so they can't be fully compiled independently without invoking an undefined function error.
我正在尝试编写一个程序,它将使用我可以在多个目录中轻松修改和编译的策略来玩游戏。游戏的大多数源文件都是不可变的(即,即使策略被改变,它们也保持不变)。假设我的源文件是a.c,b.c,c.c,d.c,e.c,其中a.c到d.c是不可变的,e.c是唯一不同策略之间不同的文件。另外,a.c调用e.c,因此如果不调用未定义的函数错误,它们就无法完全独立编译。
Is there any way to compile (cc/gcc/etc.) a.c
through d.c
into a single file, everything.o
, that I can then compile with the missing e.c
?
有没有办法将(cc / gcc / etc。)a.c到d.c编译成单个文件,everything.o,然后我可以用缺少的e.c编译?
> everything.o a.c b.c c.c d.c
> cc -g -o e.o e.c
> cc -g -o foo.o everything.o e.o
where I can copy everything.o into different directories so that I can have programs to run different strategies, without copying all four (in my case, ~20) files into each directory?
我可以将everything.o复制到不同的目录中,以便我可以让程序运行不同的策略,而不是将所有四个(在我的情况下,~20个)文件复制到每个目录中?
1 个解决方案