web-dev-qa-db-ja.com

ld:リンク時にシンボルが見つかりません

私のMac OSX 10.6では成功せずに "Loch"をコンパイルしようとしています。 「コンパイル時にシンボルが見つかりません」というエラーが常に表示されます。誰が何が問題になるのか考えていますか?

どうもありがとう

c++ -o loch -Wall getline.o lxTR.o lxOGLFT.o lxSetup.o lxRender.o lxWX.o lxImgIO.o lxLRUD.o lxFile.o lxSTree.o lxData.o lxMath.o lxSView.o lxSScene.o lxGUI.o lxGLC.o lxOptDlg.o lxAboutDlg.o img.o -lz -L/usr/X11R6/lib              -framework IOKit -framework Carbon -framework Cocoa -framework System -framework QuickTime -framework OpenGL -framework AGL  -lwx_macud_gl-2.8 -lwx_macud-2.8  -L/Applications/VTK_All/VTK_Bin/lib/vtk-5.4 -lvtkHybrid -lvtkImaging -lvtkIO -lvtkGraphics -lvtkFiltering -lvtkCommon -lvtkjpeg -lvtkpng -lvtkzlib -lvtksys -lfreetype -lGLU -lGL 
ld: warning: in /System/Library/Frameworks//QuickTime.framework/QuickTime, missing required architecture x86_64 in file
ld: warning: in /usr/lib/libwx_macud_gl-2.8.dylib, missing required architecture x86_64 in file
ld: warning: in /usr/lib/libwx_macud-2.8.dylib, missing required architecture x86_64 in file

  "wxGetTopLevelParent(wxWindow*)", referenced from:
      wxTopLevelWindowBase::IsActive()      in lxRender.o
      wxTopLevelWindowBase::IsActive()      in lxSTree.o
      wxTopLevelWindowBase::IsActive()      in lxSView.o
      wxTopLevelWindowBase::IsActive()      in lxSScene.o
      wxTopLevelWindowBase::IsActive()      in lxGUI.o
      wxTopLevelWindowBase::IsActive()      in lxOptDlg.o
      wxTopLevelWindowBase::IsActive()      in lxAboutDlg.o
  "wxWindowBase::SetVirtualSizeHints(int, int, int, int)", referenced from:
      vtable for lxRenderDataConfigin lxRender.o
      vtable for wxStaticTextBasein lxRender.o
      vtable for wxCheckBoxBasein lxRender.o
      vtable for wxButtonBasein lxRender.o
      vtable for lxModelTreeDlgin lxSTree.o
      vtable for wxButtonBasein lxSTree.o
      vtable for lxViewpointSetupDlgin lxSView.o
      vtable for wxSliderBasein lxSView.o
      vtable for wxCheckBoxBasein lxSView.o
      vtable for wxStaticTextBasein lxSView.o
      vtable for wxButtonBasein lxSView.o
      vtable for lxModelSetupDlgin lxSScene.o
      vtable for wxSliderBasein lxSScene.o
      vtable for wxStaticLineBasein lxSScene.o
      vtable for wxCheckBoxBasein lxSScene.o
      vtable for wxStaticTextBasein lxSScene.o
      vtable for wxButtonBasein lxSScene.o
      vtable for lxFramein lxGUI.o
      vtable for lxGLCanvasin lxGLC.o
      vtable for lxOptionsDlgin lxOptDlg.o
      vtable for wxDirDialogBasein lxOptDlg.o
      vtable for wxStaticTextBasein lxOptDlg.o
      vtable for wxButtonBasein lxOptDlg.o
      vtable for lxAboutDlgin lxAboutDlg.o
      vtable for wxStaticTextBasein lxAboutDlg.o
  "typeinfo for wxGLCanvas", referenced from:
      typeinfo for lxGLCanvasin lxGLC.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [loch] Error 1

次のMakefileを使用しています

# common therion objects
CMNOBJECTS = \
  lxTR.o lxOGLFT.o lxSetup.o lxRender.o lxWX.o \
  lxImgIO.o lxLRUD.o lxFile.o lxSTree.o \
  lxData.o lxMath.o lxSView.o lxSScene.o \
  lxGUI.o lxGLC.o lxOptDlg.o lxAboutDlg.o \
  img.o

VTKVERSION = 5.4
VTKLIBS = -lvtkHybrid -lvtkImaging -lvtkIO -lvtkGraphics -lvtkFiltering -lvtkCommon -lvtkjpeg -lvtkpng -lvtkzlib -lvtksys -lfreetype
POSTMAKE =
STRIPFLAG = -s 

# PLATFORM CONFIG

# PLATFORM MACOSX
  CXX = c++
  CC = cc
  VTKPATH = /Applications/VTK_All/VTK_Bin
  VTKINCLUDEPATH = $(VTKPATH)/include/vtk-5.4
  VTKLIBPATH = $(VTKPATH)/lib/vtk-5.4
  VTKLIBS = -lvtkHybrid -lvtkImaging -lvtkIO -lvtkGraphics -lvtkFiltering -lvtkCommon -lvtkjpeg -lvtkpng -lvtkzlib -lvtksys -lfreetype -lGLU -lGL
  POBJECTS = getline.o
  CXXPFLAGS = -W -Wall -DLXMACOSX $(Shell wx-config --cxxflags) -I$(VTKINCLUDEPATH) -Wno-deprecated -I/usr/X11R6/include -I/usr/X11R6/include/freetype2
  CCPFLAGS = -W -Wall -DLXMACOSX $(Shell wx-config --cflags) -I/usr/X11R6/include
  LXLIBDIR = 
  PLIBS = -lz -L/usr/X11R6/lib $(Shell wx-config --libs gl) -L$(VTKLIBPATH) $(VTKLIBS)
  POSTMAKE = cp -f ./loch ./loch.app/Contents/MacOS
  STRIPFLAG =
# PLATFORM ENDCONFIG


# BUILD CONFIG

# BUILD OZONE
##CCBFLAGS = -O3
##CXXBFLAGS = -O3
##LDBFLAGS = $(STRIPFLAG)

# BUILD OXYGEN
CCBFLAGS = -O2
CXXBFLAGS = -O2
LDBFLAGS = $(STRIPFLAG)

# BUILD RELEASE
##CCBFLAGS = 
##CXXBFLAGS = 
##LDBFLAGS = $(STRIPFLAG)

# BUILD DEBUG
##CCBFLAGS = -ggdb
##CXXBFLAGS = -ggdb -DLXDEBUG
##LDBFLAGS = 

# BUILD ENDCONFIG


# compiler settings
CXXFLAGS = -Wall -D_GNU_SOURCE -DLOCH $(CXXPFLAGS) $(CXXBFLAGS)
CCFLAGS = -Wall -D_GNU_SOURCE -DLOCH $(CCPFLAGS) $(CCBFLAGS)
OBJECTS = $(POBJECTS) $(CMNOBJECTS)

# linker settings
LIBS = $(PLIBS)
LDFLAGS = $(LDBFLAGS)


.SUFFIXES:
.SUFFIXES: .cxx .o .h .c

.cxx.o:
    $(CXX) -c $(CXXFLAGS) -o $@ $<

.c.o:
    $(CC) -c $(CCFLAGS) -o $@ $<

all: loch hlp

hlp:
    make -C ./help

loch:   $(OBJECTS)
    $(CXX) -o loch -Wall $(OBJECTS) $(LIBS) $(LDFLAGS)
    $(POSTMAKE)

loch.res: loch.rc loch.ico
    windres --include-dir e:/MSVCProjects/wxWidgets-2.6.0/include -i loch.rc -I rc -o loch.res -O coff

graphs: 
    dot -Tps graph-vispipe.dot -o graph-vispipe.ps


depend:
    Perl makedepend.pl > Makefile.dep
    Perl maketest.pl Makefile.dep
    Perl makefile.pl mv Makefile.dep Makefile
    $(CXX) -DLXDEPCHECK -DLOCH -MM *.cxx >> Makefile
    $(CC) -DLXDEPCHECK -DLOCH -MM *.c >> Makefile


config-debug:
    Perl makeconfig.pl BUILD DEBUG

test-release:
    Zip -9 loch.Zip loch.exe test.th test.jpg thconfig

config-release:
    Perl makeconfig.pl BUILD RELEASE

config-oxygen:
    Perl makeconfig.pl BUILD OXYGEN

config-ozone:
    Perl makeconfig.pl BUILD OZONE

config-linux:
    Perl makeconfig.pl PLATFORM LINUX

config-debian:
    Perl makeconfig.pl PLATFORM DEBIAN

config-win32:
    Perl makeconfig.pl PLATFORM WIN32

config-macosx:
    Perl makeconfig.pl PLATFORM MACOSX

clean:
    Perl makefile.pl rm -q *~     
    Perl makefile.pl rm -q help/*/*~
    Perl makefile.pl rm -q loch.exe
    Perl makefile.pl rm -q loch
    Perl makefile.pl rm -q loch.app/Contents/MacOS/loch
    Perl makefile.pl rm -q *.o
    Perl makefile.pl rm -q *.log
    Perl makefile.pl rm -q core
    Perl makefile.pl rmdir -q .xvpics
    Perl makefile.pl rm -q *.bmp
    Perl makefile.pl rm -q *.ppm
    Perl makefile.pl rm -q *.Zip
    Perl makefile.pl rm -q *.pdf
    Perl makefile.pl rm -q *.png



# DEPENDENCIES
lxAboutDlg.o: lxAboutDlg.cxx lxWX.h icons/about.xpm ../thversion.h
lxData.o: lxData.cxx lxData.h lxMath.h lxImgIO.h lxFile.h lxLRUD.h
lxFile.o: lxFile.cxx lxFile.h lxMath.h img.h
lxGLC.o: lxGLC.cxx lxGLC.h lxMath.h lxGUI.h lxData.h lxImgIO.h lxFile.h \
  lxSetup.h lxSView.h lxWX.h lxFNT6x13_bdf.h lxFNT10x20_bdf.h \
  lxFNTFreeSans_ttf.h lxRender.h lxTR.h
lxGUI.o: lxGUI.cxx lxGUI.h lxGLC.h lxMath.h lxData.h lxImgIO.h lxFile.h \
  lxSetup.h lxRender.h lxOptDlg.h lxAboutDlg.h lxSView.h lxWX.h \
  lxSScene.h icons/open.xpm icons/render.xpm icons/reload.xpm \
  icons/stereo.xpm icons/rotation.xpm icons/lockrot.xpm icons/fit.xpm \
  icons/home.xpm icons/rendersetup.xpm icons/plan.xpm icons/profile.xpm \
  icons/fullscreen.xpm icons/orto.xpm icons/camera.xpm icons/scene.xpm \
  icons/viscline.xpm icons/vissurface.xpm icons/visbbox.xpm \
  icons/viswalls.xpm icons/visinds.xpm loch.xpm
lxImgIO.o: lxImgIO.cxx lxImgIO.h
lxLRUD.o: lxLRUD.cxx lxLRUD.h lxMath.h
lxMath.o: lxMath.cxx lxMath.h
lxOGLFT.o: lxOGLFT.cxx lxOGLFT.h
lxOptDlg.o: lxOptDlg.cxx lxWX.h lxGUI.h lxGLC.h lxMath.h
lxRender.o: lxRender.cxx lxRender.h lxWX.h lxGLC.h lxMath.h lxGUI.h \
  lxSetup.h lxData.h lxImgIO.h lxFile.h lxTR.h
lxSScene.o: lxSScene.cxx lxSScene.h lxWX.h lxGUI.h lxGLC.h lxMath.h \
  lxSetup.h lxData.h lxImgIO.h lxFile.h loch.xpm
lxSView.o: lxSView.cxx lxSView.h lxWX.h lxGUI.h lxGLC.h lxMath.h \
  lxSetup.h lxData.h lxImgIO.h lxFile.h loch.xpm
lxSetup.o: lxSetup.cxx lxSetup.h lxData.h lxMath.h lxImgIO.h lxFile.h
lxWX.o: lxWX.cxx lxWX.h
getline.o: getline.c
img.o: img.c img.h
lxR2D.o: lxR2D.c lxR2D.h
lxR2P.o: lxR2P.c lxR2P.h
lxTR.o: lxTR.c lxTR.h

今追加-m32が新しいエラーを取得

c++ -m32 -o loch -Wall getline.o lxTR.o lxOGLFT.o lxSetup.o lxRender.o lxWX.o lxImgIO.o lxLRUD.o lxFile.o lxSTree.o lxData.o lxMath.o lxSView.o lxSScene.o lxGUI.o lxGLC.o lxOptDlg.o lxAboutDlg.o img.o -lz -L/usr/X11R6/lib              -framework IOKit -framework Carbon -framework Cocoa -framework System -framework QuickTime -framework OpenGL -framework AGL  -lwx_macud_gl-2.8 -lwx_macud-2.8  -L/Applications/VTK_All/VTK_Bin/lib/vtk-5.4 -lvtkHybrid -lvtkImaging -lvtkIO -lvtkGraphics -lvtkFiltering -lvtkCommon -lvtkjpeg -lvtkpng -lvtkzlib -lvtksys -lfreetype -lGLU -lGL 
ld: warning: in /Applications/VTK_All/VTK_Bin/lib/vtk-5.4/libvtkHybrid.a, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Applications/VTK_All/VTK_Bin/lib/vtk-5.4/libvtkImaging.a, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Applications/VTK_All/VTK_Bin/lib/vtk-5.4/libvtkIO.a, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Applications/VTK_All/VTK_Bin/lib/vtk-5.4/libvtkGraphics.a, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Applications/VTK_All/VTK_Bin/lib/vtk-5.4/libvtkFiltering.a, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Applications/VTK_All/VTK_Bin/lib/vtk-5.4/libvtkCommon.a, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Applications/VTK_All/VTK_Bin/lib/vtk-5.4/libvtkjpeg.a, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Applications/VTK_All/VTK_Bin/lib/vtk-5.4/libvtkpng.a, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Applications/VTK_All/VTK_Bin/lib/vtk-5.4/libvtkzlib.a, file was built for unsupported file format which is not the architecture being linked (i386)
ld: warning: in /Applications/VTK_All/VTK_Bin/lib/vtk-5.4/libvtksys.a, file was built for unsupported file format which is not the architecture being linked (i386)
Undefined symbols:
15
Chris

64ビットソフトウェア用にコンパイルしているようですが、コンパイラが検出しているライブラリは32ビットソフトウェア用です。

既存のライブラリを使用できるように32ビットモードでコードを再コンパイルするか、64ビットバージョンのライブラリの場所をインストール(または検索)して指定する必要があります。

32ビットビルドの場合、次を使用できます。

BITTINESS = -m32
CC = cc ${BITTINESS}
CXX = c++ ${BITTINESS}

コマンドラインで 'make BITTINESS=-m64 '後でしたい場合。

ある種のユニバーサルバイナリが必要であることを指定する他の方法もあります。ただし、そのアーキテクチャ用にビルドする場合は、x86_64をサポートするWX(およびQuickTime)ライブラリのバージョンを見つける必要があります。


MacOS Xでファイルの種類を識別する方法

Dylibの場合は、fileを使用します。

$ file /usr/lib/libffi.dylib
/usr/lib/libffi.dylib: Mach-O universal binary with 3 architectures
/usr/lib/libffi.dylib (for architecture x86_64):    Mach-O 64-bit dynamically linked shared library x86_64
/usr/lib/libffi.dylib (for architecture i386):  Mach-O dynamically linked shared library i386
/usr/lib/libffi.dylib (for architecture ppc7400):   Mach-O dynamically linked shared library ppc
$

アーカイブの場合、オブジェクトファイルを抽出します。

$ file libjlss-350.a
libjlss-350.a: current ar archive random library
$ ar x libjlss-350.a stuint8.o
$ file stuint8.o
stuint8.o: Mach-O 64-bit object x86_64
$
14