我不是以英语为母语的人,但我会尽力用英语交流。
对于自制程序,我需要一些库(来自其他人)。在我的第一台 Linux PC 上它可以工作,但现在在这台 PC 上它不工作了。我使用 安装程序sudo make
,并将库复制到/usr/local/lib/
。
现在我尝试编译我的程序,g++ -g -o cv countvertices.c -lQuantim4 -lm -ltiff -lPSgraf3
它显示:
/usr/bin/ld: skipping incompatible /usr/local/lib/libQuantim4.a when searching for -lQuantim4
/usr/bin/ld: cannot find -lQuantim4
/usr/bin/ld: skipping incompatible /usr/local/lib/libPSgraf3.a when searching for -lPSgraf3
/usr/bin/ld: cannot find -lPSgraf3
collect2: ld gab 1 als Ende-Status zurück
我搜索了一下这个错误信息,看起来它与 32/64 位版本有关。处理器是 AMD Athlon(tm) II X2 215 处理器 × 2。我使用 windows 安装程序 wubi 安装了 Ubuntu 11.10. 桌面版 (i386)。所以现在我有了 32 位版本的 Ubuntu。
有人知道如何解决这个问题吗?或者有没有办法查看库是 32 位还是 64 位?
谢谢你的回答,steabert。
库架构是 x86_64。但我认为如果我运行 makefile,就会创建适当的架构。Quantim4 的 makefile 如下所示:
# make
#
#
# Quantim library (version 2.0)
#
NAME = libQuantim4
#
VPATH = /usr/include
#
CC = g++
#
# source files
#
CFILES = SavePaletteImage.c SaveShiftImage.c SetFrame.c StretchHisto.c bAddition.c bContour.c bErode.c bLogAnd.c bLogOr.c bObjects.c gBibin.c gBin.c gBilevel.c gBinTwoLevel.c gErode.c b2DEuler.c pDisector.c BtdErode.c BtdErodeFilter.c BtdOpen.c BtdContinuity.c SetBtdShell.c DLine.c bContourCent.c RGBtoGray.c StretchRGBHisto.c StretchRGBBright.c ran3.c GetRandDDDImage.c CreateDDDImage.c gDiff.c error.c DddMinMax.c DddBin.c DddClas.c BtdEuler.c DddHisto.c DddCircHisto.c DddEulerFunc.c psPlot.c psDddCircHisto.c qdefault.c GetCorDDDImage.c grf3.c GetDddGreyCdf.c psMultiPlot.c gLaplace.c gSobel.c gHisto.c psHisto.c bThinning.c bConCom.c bHitMiss.c DddResRed.c GetDddAcov.c gRedRes.c BtdVolSurf.c BtdSkelet.c BtdDiffusionZ.c BtdEuler26.c BtdEuler6.c BtdMeancurv.c BtdQuant.c BtdSurfdens.c BtdVoldens.c GetAcov.c GetCorImage.c GetGreyCdf.c MinMaxf.c gConfunc.c bConCom2.c gCircMask.c bRemObjects.c GetCorDDDImage2.c Btd2Ddd.c grf2ext.c GetSemiVar.c psMultiPlotTit.c psPlotTit.c utils.c GetVoronoiTes.c GetPercolClus.c bQuant.c bEuler4.c bEuler8.c bLengthdens.c bSurfdens.c bVoldens.c bAverageCurvature.c DddBibin.c gHistoMatch.c rgb-utils.c BtdQuantMask.c bQuantMask.c bQuantRecMask.c bErodeMark.c bGetDistMap.c BtdDrawSphere.c BtdErodeMir.c BtdGetDistMap.c BtdGetDistOpenMap.c DDD2Dx.c DddDrawCylinder.c DddWaterShed.c gWaterShed.c SetDddShell.c bErodeMir.c bErodeMirCirc.c bGetDistOpenMap.c bThinning8.c BtdGetDistOpenMapDouble.c BtdErodeMirDouble.c ps3Dview.c GetRandImage.c files.c pixelrw.c transforms.c filters.c mathmorph.c bGetFullDistMap.c evaluations.c binarization.c Erode_Open.c greyscale.c minkowski.c binimages.c CircMask.c bConLength.c\
${NULL}
#
# compiler flags
#
CFLAGS = -O3 -w -r -L/usr/lib -L ~/local/lib -I ~/local/include
#
# rules
#
SRCFILES = $(CFILES)
OBJFILES = $(CFILES:%.c=../bin/%.o)
$(NAME): compile createLibrary;
compile: $(OBJFILES)
# touch emptyfile
# $(CC) -o $@ $(CFLAGS) $(OBJFILES) -ltiff -lm
$(OBJFILES): ../bin/%.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
createLibrary:
ar r libQuantim4.a $(OBJFILES)
ranlib libQuantim4.a
cp libQuantim4.a /usr/local/lib/libQuantim4.a
cp quantim4.h /usr/local/include/
clean:
rm -f ../bin/*.o
如果我使用“sudo make”运行它,为什么我实际上有 i386 却得到 x86_64 库?
当我尝试以普通用户身份进行编译时的日志:
make | tee build.log
ar: creating libQuantim4.a
ar r libQuantim4.a ../bin/SavePaletteImage.o ../bin/SaveShiftImage.o ../bin/SetFrame.o ../bin/StretchHisto.o ../bin/bAddition.o ../bin/bContour.o ../bin/bErode.o ../bin/bLogAnd.o ../bin/bLogOr.o ../bin/bObjects.o ../bin/gBibin.o ../bin/gBin.o ../bin/gBilevel.o ../bin/gBinTwoLevel.o ../bin/gErode.o ../bin/b2DEuler.o ../bin/pDisector.o ../bin/BtdErode.o ../bin/BtdErodeFilter.o ../bin/BtdOpen.o ../bin/BtdContinuity.o ../bin/SetBtdShell.o ../bin/DLine.o ../bin/bContourCent.o ../bin/RGBtoGray.o ../bin/StretchRGBHisto.o ../bin/StretchRGBBright.o ../bin/ran3.o ../bin/GetRandDDDImage.o ../bin/CreateDDDImage.o ../bin/gDiff.o ../bin/error.o ../bin/DddMinMax.o ../bin/DddBin.o ../bin/DddClas.o ../bin/BtdEuler.o ../bin/DddHisto.o ../bin/DddCircHisto.o ../bin/DddEulerFunc.o ../bin/psPlot.o ../bin/psDddCircHisto.o ../bin/qdefault.o ../bin/GetCorDDDImage.o ../bin/grf3.o ../bin/GetDddGreyCdf.o ../bin/psMultiPlot.o ../bin/gLaplace.o ../bin/gSobel.o ../bin/gHisto.o ../bin/psHisto.o ../bin/bThinning.o ../bin/bConCom.o ../bin/bHitMiss.o ../bin/DddResRed.o ../bin/GetDddAcov.o ../bin/gRedRes.o ../bin/BtdVolSurf.o ../bin/BtdSkelet.o ../bin/BtdDiffusionZ.o ../bin/BtdEuler26.o ../bin/BtdEuler6.o ../bin/BtdMeancurv.o ../bin/BtdQuant.o ../bin/BtdSurfdens.o ../bin/BtdVoldens.o ../bin/GetAcov.o ../bin/GetCorImage.o ../bin/GetGreyCdf.o ../bin/MinMaxf.o ../bin/gConfunc.o ../bin/bConCom2.o ../bin/gCircMask.o ../bin/bRemObjects.o ../bin/GetCorDDDImage2.o ../bin/Btd2Ddd.o ../bin/grf2ext.o ../bin/GetSemiVar.o ../bin/psMultiPlotTit.o ../bin/psPlotTit.o ../bin/utils.o ../bin/GetVoronoiTes.o ../bin/GetPercolClus.o ../bin/bQuant.o ../bin/bEuler4.o ../bin/bEuler8.o ../bin/bLengthdens.o ../bin/bSurfdens.o ../bin/bVoldens.o ../bin/bAverageCurvature.o ../bin/DddBibin.o ../bin/gHistoMatch.o ../bin/rgb-utils.o ../bin/BtdQuantMask.o ../bin/bQuantMask.o ../bin/bQuantRecMask.o ../bin/bErodeMark.o ../bin/bGetDistMap.o ../bin/BtdDrawSphere.o ../bin/BtdErodeMir.o ../bin/BtdGetDistMap.o ../bin/BtdGetDistOpenMap.o ../bin/DDD2Dx.o ../bin/DddDrawCylinder.o ../bin/DddWaterShed.o ../bin/gWaterShed.o ../bin/SetDddShell.o ../bin/bErodeMir.o ../bin/bErodeMirCirc.o ../bin/bGetDistOpenMap.o ../bin/bThinning8.o ../bin/BtdGetDistOpenMapDouble.o ../bin/BtdErodeMirDouble.o ../bin/ps3Dview.o ../bin/GetRandImage.o ../bin/files.o ../bin/pixelrw.o ../bin/transforms.o ../bin/filters.o ../bin/mathmorph.o ../bin/bGetFullDistMap.o ../bin/evaluations.o ../bin/binarization.o ../bin/Erode_Open.o ../bin/greyscale.o ../bin/minkowski.o ../bin/binimages.o ../bin/CircMask.o ../bin/bConLength.o
ranlib libQuantim4.a
cp libQuantim4.a /usr/local/lib/libQuantim4.a
cp: reguläre Datei „/usr/local/lib/libQuantim4.a“ kann nicht angelegt werden: Keine Berechtigung
make: *** [createLibrary] Fehler 1
build.log的内容:
ar r libQuantim4.a ../bin/SavePaletteImage.o ../bin/SaveShiftImage.o ../bin/SetFrame.o ../bin/StretchHisto.o ../bin/bAddition.o ../bin/bContour.o ../bin/bErode.o ../bin/bLogAnd.o ../bin/bLogOr.o ../bin/bObjects.o ../bin/gBibin.o ../bin/gBin.o ../bin/gBilevel.o ../bin/gBinTwoLevel.o ../bin/gErode.o ../bin/b2DEuler.o ../bin/pDisector.o ../bin/BtdErode.o ../bin/BtdErodeFilter.o ../bin/BtdOpen.o ../bin/BtdContinuity.o ../bin/SetBtdShell.o ../bin/DLine.o ../bin/bContourCent.o ../bin/RGBtoGray.o ../bin/StretchRGBHisto.o ../bin/StretchRGBBright.o ../bin/ran3.o ../bin/GetRandDDDImage.o ../bin/CreateDDDImage.o ../bin/gDiff.o ../bin/error.o ../bin/DddMinMax.o ../bin/DddBin.o ../bin/DddClas.o ../bin/BtdEuler.o ../bin/DddHisto.o ../bin/DddCircHisto.o ../bin/DddEulerFunc.o ../bin/psPlot.o ../bin/psDddCircHisto.o ../bin/qdefault.o ../bin/GetCorDDDImage.o ../bin/grf3.o ../bin/GetDddGreyCdf.o ../bin/psMultiPlot.o ../bin/gLaplace.o ../bin/gSobel.o ../bin/gHisto.o ../bin/psHisto.o ../bin/bThinning.o ../bin/bConCom.o ../bin/bHitMiss.o ../bin/DddResRed.o ../bin/GetDddAcov.o ../bin/gRedRes.o ../bin/BtdVolSurf.o ../bin/BtdSkelet.o ../bin/BtdDiffusionZ.o ../bin/BtdEuler26.o ../bin/BtdEuler6.o ../bin/BtdMeancurv.o ../bin/BtdQuant.o ../bin/BtdSurfdens.o ../bin/BtdVoldens.o ../bin/GetAcov.o ../bin/GetCorImage.o ../bin/GetGreyCdf.o ../bin/MinMaxf.o ../bin/gConfunc.o ../bin/bConCom2.o ../bin/gCircMask.o ../bin/bRemObjects.o ../bin/GetCorDDDImage2.o ../bin/Btd2Ddd.o ../bin/grf2ext.o ../bin/GetSemiVar.o ../bin/psMultiPlotTit.o ../bin/psPlotTit.o ../bin/utils.o ../bin/GetVoronoiTes.o ../bin/GetPercolClus.o ../bin/bQuant.o ../bin/bEuler4.o ../bin/bEuler8.o ../bin/bLengthdens.o ../bin/bSurfdens.o ../bin/bVoldens.o ../bin/bAverageCurvature.o ../bin/DddBibin.o ../bin/gHistoMatch.o ../bin/rgb-utils.o ../bin/BtdQuantMask.o ../bin/bQuantMask.o ../bin/bQuantRecMask.o ../bin/bErodeMark.o ../bin/bGetDistMap.o ../bin/BtdDrawSphere.o ../bin/BtdErodeMir.o ../bin/BtdGetDistMap.o ../bin/BtdGetDistOpenMap.o ../bin/DDD2Dx.o ../bin/DddDrawCylinder.o ../bin/DddWaterShed.o ../bin/gWaterShed.o ../bin/SetDddShell.o ../bin/bErodeMir.o ../bin/bErodeMirCirc.o ../bin/bGetDistOpenMap.o ../bin/bThinning8.o ../bin/BtdGetDistOpenMapDouble.o ../bin/BtdErodeMirDouble.o ../bin/ps3Dview.o ../bin/GetRandImage.o ../bin/files.o ../bin/pixelrw.o ../bin/transforms.o ../bin/filters.o ../bin/mathmorph.o ../bin/bGetFullDistMap.o ../bin/evaluations.o ../bin/binarization.o ../bin/Erode_Open.o ../bin/greyscale.o ../bin/minkowski.o ../bin/binimages.o ../bin/CircMask.o ../bin/bConLength.o
ranlib libQuantim4.a
cp libQuantim4.a /usr/local/lib/libQuantim4.a
图书馆架构:
objdump -a /usr/local/lib/libQuantim4.a
In archive /usr/local/lib/libQuantim4.a:
SavePaletteImage.o: file format elf64-x86-64
rw------- 1000/1000 4248 Jan 16 21:33 2011 SavePaletteImage.o
SaveShiftImage.o: file format elf64-x86-64
rw------- 1000/1000 2280 Jan 16 21:33 2011 SaveShiftImage.o
...
但等一下,x86 是 32 位的,对吧?i386 也是 32 位的。那么问题出在哪里呢?
答案1
我最终通过安装 Ubuntu 11.10.amd64 解决了这个问题,尽管我希望有更好的方法......
答案2
要找出库档案是针对哪种体系结构编译的,请运行命令
$ objdump -a /usr/local/lib/libQuantim4.a
库存档的目标体系结构需要与您编译时生成的目标文件的体系结构相匹配。您的选择:
- 获取正确架构的库文件或重新编译该库。
- 交叉编译到与您的库相同的架构。
第二个选项要求目标体系结构中所有必需的库都可用(例如 libc),并且生成的代码将无法在该 Ubuntu 安装下运行。因此,如果打算在 Ubuntu i386 下运行它,我会选择第一个选项。
如果库目标架构是 x86_64,并且无法获取 i386 的库,则可以安装 Ubuntu 64 位。