简体   繁体   English

为ubuntu编写cygwin makefile

[英]writing a cygwin makefile for ubuntu

I am trying to compile the open-source AAM-library. 我正在尝试编译开源AAM库。 I have tried in Visual Studio, and although it compiled, it had a run-time error. 我曾在Visual Studio中尝试过,尽管已编译,但出现了运行时错误。 Now I'm trying to compile it in Ubuntu 11.04 using G++. 现在,我正在尝试使用G ++在Ubuntu 11.04中对其进行编译。 The only makefile provided is a cygwin makefile. 提供的唯一makefile是cygwin makefile。 I am trying to use this to compile in Ubuntu. 我正在尝试使用它在Ubuntu中进行编译。 (I have included the makefile below). (我在下面包含了makefile)。 The problem I am having is near the bottom in the lines: 我遇到的问题在行的底部附近:

libaamlibrary.dll.a: $(OBJS)
        g++ -fPIC -shared $(OBJS) $(LIBS) -o cygaamlibrary-2.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker libaamlibrary.dll.a

"--enable-auto-image-base" is not a recognised option. “ --enable-auto-image-base”不是公认的选项。 I am trying to rewrite these 3 lines to a form that does the same thing but works in Ubuntu, but I am struggling, because I don't really understand what the lines are doing (eg, I don't understand Xlinker and how it should be used). 我试图将这3行重写为一种功能相同但可以在Ubuntu中使用的形式,但是我很挣扎,因为我不太了解这些行的功能(例如,我不了解Xlinker及其运行方式)应该使用)。 Any advice would be much appreciated... Here is the full makefile for reference: 任何建议将不胜感激...这里是完整的makefile供参考:

CPPFLAGS = -I. -I/home/andrew/MscProject/OpenCV-2.3.0/include/opencv -O2 -Wall -g -MD -fPIC
PROGRAMS = libaamlibrary.dll.a  libaamlibrary.a fit build 
LIBS = -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann  
OBJS = AAM_Util.o VJfacedetect.o AAM_Shape.o AAM_CAM.o AAM_PAW.o AAM_PDM.o AAM_TDM.o AAM_MovieAVI.o AAM_Basic.o AAM_IC.o

all: $(PROGRAMS)

AAM_Util.o: AAM_Util.cpp AAM_Util.h 
    g++  $(CPPFLAGS)  -c -o AAM_Util.o AAM_Util.cpp

AAM_Shape.o: AAM_Shape.cpp AAM_Shape.h
    g++  $(CPPFLAGS)  -c -o AAM_Shape.o AAM_Shape.cpp

AAM_TDM.o: AAM_TDM.cpp AAM_TDM.h 
    g++  $(CPPFLAGS)  -c -o AAM_TDM.o AAM_TDM.cpp

AAM_PDM.o: AAM_PDM.cpp AAM_PDM.h 
    g++  $(CPPFLAGS)  -c -o AAM_PDM.o AAM_PDM.cpp

AAM_PAW.o: AAM_PAW.cpp AAM_PAW.h
    g++  $(CPPFLAGS)  -c -o AAM_PAW.o AAM_PAW.cpp

AAM_CAM.o: AAM_CAM.cpp AAM_CAM.h 
    g++  $(CPPFLAGS)  -c -o AAM_CAM.o AAM_CAM.cpp

VJfacedetect.o: VJfacedetect.cpp VJfacedetect.h 
    g++  $(CPPFLAGS)  -c -o VJfacedetect.o VJfacedetect.cpp

AAM_MovieAVI.o: AAM_MovieAVI.cpp AAM_MovieAVI.h
    g++  $(CPPFLAGS)  -c -o AAM_MovieAVI.o AAM_MovieAVI.cpp

AAM_Basic.o: AAM_Basic.cpp AAM_Basic.h
    g++  $(CPPFLAGS)  -c -o AAM_Basic.o AAM_Basic.cpp

AAM_IC.o: AAM_IC.cpp AAM_IC.h 
    g++  $(CPPFLAGS)  -c -o AAM_IC.o AAM_IC.cpp

demo_build.o: train.cpp
    g++  $(CPPFLAGS)  -c -o demo_build.o train.cpp

demo_fit.o: fit.cpp
    g++  $(CPPFLAGS)  -c -o demo_fit.o fit.cpp

libaamlibrary.a: $(OBJS) 
    ar cru libaamlibrary.a $(OBJS)
    ranlib libaamlibrary.a

libaamlibrary.dll.a: $(OBJS)
    g++ -fPIC -shared $(OBJS) $(LIBS) -o cygaamlibrary-2.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker libaamlibrary.dll.a

fit: demo_fit.o
    g++ -o fit demo_fit.o libaamlibrary.dll.a $(LIBS) 

build: demo_build.o
    g++ -o build demo_build.o libaamlibrary.dll.a $(LIBS)

clean:
    rm -f *.o $(PROGRAMS)

Practical approach: first try building without all the .dll and .dll.a stuff; 实用方法:首先尝试在没有所有.dll.dll.a内容的情况下进行构建; just remove the lines that refer to such targets. 只需删除引用此类目标的行即可。

It seems .dll.a files are static archives containing position-independent code (PIC), which are necessary in advanced linking scenarios, ie if you're developing shared libraries yourself. 似乎.dll.a文件是包含位置独立代码(PIC)的静态存档,在高级链接方案中,例如,如果您自己在开发共享库,则这是必需的。 (Even if you want such a thing, you shouldn't call it .dll.a on Linux.) (即使您想要这样的东西,在Linux上也不应将其.dll.a 。)

I agree that you should not use a .dll.a or .dll extension (I believe .a and .so are appropriate), but it seems you can't do without libaamlibrary[.dll].a. 我同意您不应该使用.dll.a或.dll扩展名(我相信.a和.so是合适的),但是似乎没有libaamlibrary [.dll] .a是您无法做到的。

Since '--enable-auto-image-base' is prefixed with -Wl, this makes it a linker (ld) option. 由于'--enable-auto-image-base'的前缀为-Wl,因此使其成为链接器(ld)选项。

I searched 'man ld' and came up with this: 我搜索了“人ld”,并提出了以下建议:

--enable-auto-image-base Automatically choose the image base for DLLs, unless one is specified using the "--image-base" argument. --enable-auto-image-base自动选择DLL的映像库,除非使用“ --image-base”参数指定了映像库。 By using a hash generated from the dllname to create unique image bases for each DLL, in-memory collisions and relocations which can delay program execution are avoided. 通过使用从dllname生成的哈希值为每个DLL创建唯一的映像库,避免了可能会延迟程序执行的内存冲突和重定位。 [This option is specific to the i386 PE targeted port of the linker] [此选项特定于链接器的以i386 PE为目标的端口]

What is your platform? 您的平台是什么? It is not available to non i386 architectures as I understand, and maybe not needed? 据我了解,它不适用于非i386架构,也许不需要吗? So can you try compiling without it? 那么,如果没有它,您可以尝试编译吗?

By the way I recommend using the excellent Autotools package (automake/autoconf/libtool). 顺便说一句,我建议使用出色的Autotools软件包(automake / autoconf / libtool)。

Regarding --out-implib it is also not available on amd64. 关于--out-implib,它在amd64上也不可用。

--out-implib file The linker will create the file file which will contain an import lib corresponding to the DLL the linker is generating. --out-implib文件链接器将创建文件文件,该文件将包含与链接器生成的DLL相对应的导入lib。 This import lib (which should be called " .dll.a" or " .a" may be used to link clients against the generated DLL; this behaviour makes it possible to skip a separate "dlltool" import library creation step. [This option is specific to the i386 PE targeted port of the linker] 此导入库(应称为“ .dll.a”或“ .a”可用于将客户端链接到生成的DLL;此行为可以跳过单独的“ dlltool”导入库创建步骤。特定于链接器的i386 PE目标端口]

Sorry but I don't know what an import lib is. 抱歉,我不知道导入库是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM