问题描述
我搜索了此问题的答案,但找不到任何好处.也许它们很旧,并且有些变化,所以我再问一遍.
I searched for the answer to this question but couldn't find any good. Maybe they're old and something has changed, so I ask again.
我的目录结构为:
my_project
my_project
-
src
src
bin
我想要的是,当我在根目录中创建时,二进制文件放在./bin中,而不是混乱的./src.但是如何?
I want that, when I do make in the root dir, the binaries are put in ./bin, instead of cluttering ./src. But how?
我正在使用C ++.我的Makefile.am没有什么特别的.只是bin_PROGRAM和_SOURCES变量.
I am using C++. My Makefile.am has nothing special. Just the bin_PROGRAM and _SOURCES variables.
当我运行make时,生成的二进制文件被放入./src中.我只想要它们在./bin中.
When I run make, the binaries generated are put into ./src. I simply want them in ./bin.
推荐答案
您在这里有错误的主意.
You've got the wrong idea here.
您运行configure
的位置都将是您的构建树.这就是autoconf设计的工作方式.程序包的用户(不想使他们的源代码树变得混乱)会期望它以这种方式工作.
Your build tree is wherever you run configure
. That's how autoconf is designed to work. Users of your package (who do not want to clutter their source tree) will expect it to work this way.
这种方法是一种更通用的解决方案,具有比您想象中的组织更大的灵活性.例如,想要维护源并在单独的文件系统上构建文件并不是很不寻常.
This approach is a more general solution with a lot more flexibility than the organization you're imagining. For instance, it's not terribly unusual to want to maintain sources and build files on separate filesystems.
这篇关于自动生成生成二进制文件到bin/而不是src/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!