2014-12-16 1 views
0

xcode를 사용하여 mac osx yosemite에서 conv-net 라이브러리를 컴파일하려고합니다. 심지어 libstdC++ 플래그를 설정해도 여전히 제대로 연결되지 않습니다.x86_64에 대한 정의되지 않은 심볼 Cmake

아직 아키텍처 x86_64의 정의되지 않은 기호가 나타납니다. 도움을 주시면 감사하겠습니다.

sh-3.2# ./compile.sh 
Building conv-net library 
-- The C compiler identification is AppleClang 6.0.0.6000056 
-- The CXX compiler identification is AppleClang 6.0.0.6000056 
-- Check for working C compiler: /usr/bin/cc 
-- Check for working C compiler: /usr/bin/cc -- works 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - done 
-- Check for working CXX compiler: /usr/bin/c++ 
-- Check for working CXX compiler: /usr/bin/c++ -- works 
-- Detecting CXX compiler ABI info 
-- Detecting CXX compiler ABI info - done 
-- Configuring done 
WARNING: Target "testimg" requests linking to directory "/usr/local/Cellar/opencv/2.4.9/lib". Targets may link only to libraries. CMake is dropping the item. 
WARNING: Target "testimg" requests linking to directory "/usr/local/Cellar/opencv/2.4.9/lib". Targets may link only to libraries. CMake is dropping the item. 
WARNING: Target "testmnist" requests linking to directory "/usr/local/Cellar/opencv/2.4.9/lib". Targets may link only to libraries. CMake is dropping the item. 
WARNING: Target "testmnist" requests linking to directory "/usr/local/Cellar/opencv/2.4.9/lib". Targets may link only to libraries. CMake is dropping the item. 
-- Generating done 
-- Build files have been written to: /var/tmp/conv-net-0.1-prealpha_buildroot 
Scanning dependencies of target cvconvnet 
[ 11%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvsubsamplingplane.cpp.o 
[ 22%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvconvolutionplane.cpp.o 
[ 33%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvgenericplane.cpp.o 
[ 44%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvsourceplane.cpp.o 
[ 55%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvrbfplane.cpp.o 
[ 66%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvmaxplane.cpp.o 
[ 77%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvconvnetparser.cpp.o 
[ 88%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvfastsigmoid.cpp.o 
[100%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvconvnet.cpp.o 
/Users/prabhubalakrishnan/Desktop/conv-net/src/cvconvnet.cpp:169:1: warning: control reaches end of non-void function [-Wreturn-type] 
} 
^ 
1 warning generated. 
Linking CXX static library libcvconvnet.a 
[100%] Built target cvconvnet 
Scanning dependencies of target testimg 
Linking CXX executable testimg 
Undefined symbols for architecture x86_64: 
    "_main", referenced from: 
    implicit entry/start for main executable 
ld: symbol(s) not found for architecture x86_64 
clang: error: linker command failed with exit code 1 (use -v to see invocation) 
make[2]: *** [testimg] Error 1 
make[1]: *** [CMakeFiles/testimg.dir/all] Error 2 
make: *** [all] Error 2 
cp: testimg: No such file or directory 
cp: testmnist: No such file or directory 
ls: illegal option -- I 
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...] 

이 내 메이크 파일

cmake_minimum_required(VERSION 3.0) 
PROJECT (CvConvolutionalNet) 
set (CMAKE_CXX_FLAGS " -stdlib=libstdc++") 
# IF() ENDIF() statements 
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) 

# Specify build-type as Debug if not specified already 
IF (NOT CMAKE_BUILD_TYPE) 
    SET(CMAKE_BUILD_TYPE Debug) 
ENDIF() 

# Produce verbose makefiles 
# SET(CMAKE_VERBOSE_MAKEFILE ON) 

# Sources for library 
SET(CVCONVNET_SRCS 
    src/cvsubsamplingplane.cpp 
    src/cvconvolutionplane.cpp 
    src/cvgenericplane.cpp 
    src/cvsourceplane.cpp 
    src/cvrbfplane.cpp 
    src/cvmaxplane.cpp 
    src/cvconvnetparser.cpp 
    src/cvfastsigmoid.cpp 
    src/cvconvnet.cpp 
) 

# Sources for test files 
SET(TESTIMG_SRCS tst/) 
SET(TESTMNIST_SRCS tst/) 

set (CV_H /usr/local/Cellar/opencv/2.4.9/include/opencv) 
set (HIGHGUI_H src/include) 
set (LIBCV /usr/local/Cellar/opencv/2.4.9/lib) 
set (LIBHIGHGUI /usr/local/Cellar/opencv/2.4.9/lib) 

# Here are common paths (in addition to default paths) 
SET (INCLUDE_SEARCH_PATH 
    /usr/local/include /usr/include /usr/include/opencv/ 
    /usr/include/opencv/ c:/program\ files/opencv/include 
) 

SET (LIBRARY_SEARCH_PATH 
    /usr/local/lib /usr/lib c:/program\ files/opencv/lib c:/windows/system32 
) 

# Find OpenCV and Expat 
FIND_PATH(CV_H NAMES cv.h PATHS ${INCLUDE_SEARCH_PATH}) 
FIND_PATH(HIGHGUI_H NAMES highgui.h PATHS ${INCLUDE_SEARCH_PATH}) 
FIND_PATH(EXPAT_H NAMES expat.h PATHS ${INCLUDE_SEARCH_PATH}) 

FIND_LIBRARY(LIBCV NAMES cv PATHS ${LIBRARY_SEARCH_PATH}) 
FIND_LIBRARY(LIBHIGHGUI NAMES highgui PATHS ${LIBRARY_SEARCH_PATH}) 
FIND_LIBRARY(LIBEXPAT NAMES expat PATHS ${LIBRARY_SEARCH_PATH}) 

INCLUDE_DIRECTORIES(include/ ${CV_H} ${HIGHGUI_H} ${EXPAT_H}) 

# Here is out library 
ADD_LIBRARY(cvconvnet STATIC ${CVCONVNET_SRCS}) 

# Here are our test programs 
ADD_EXECUTABLE(testimg ${TESTIMG_SRCS}) 
ADD_EXECUTABLE(testmnist ${TESTMNIST_SRCS}) 

# Compiler options are different for Release and Debug 
IF (CMAKE_BUILD_TYPE MATCHES Release) 
    # Highly optimized + cancel all assert()s 
    ADD_DEFINITIONS(-O3 -DNDEBUG) 
ELSE() 
    # Include debug info, profiling info, some text output 
    ADD_DEFINITIONS(-O -pg -g -DDEBUG) 
    # Set profiling for linker too 
    SET_TARGET_PROPERTIES(testmnist PROPERTIES LINK_FLAGS "-pg") 
ENDIF() 

# We should link our test programs to libraries 
TARGET_LINK_LIBRARIES(testimg cvconvnet ${LIBCV} ${LIBHIGHGUI} ${LIBEXPAT}) 
TARGET_LINK_LIBRARIES(testmnist cvconvnet ${LIBCV} ${LIBHIGHGUI} ${LIBEXPAT}) 

답변

2

add_executable 명령은 대상 이름과 소스 파일의 목록 컴파일을 걸립니다. testimg에 대한 대상을 만들 때 디렉토리를 전달합니다.

file(GLOB ...) 명령을 사용하여 디렉토리의 모든 소스 파일을 목록 변수로 수집하고이를 add_executable 호출에 전달하십시오.

6

컴파일러 플래그에 -c 옵션을 추가하여 수정했습니다.

+0

간결하고 좋은 답변입니다. 감사. – submartingale

+0

이 솔루션은 저와 함께 작동합니다 –

+2

명확히하기 위해'-c' 옵션을 추가하려면 다음을 사용하십시오 :'set (CMAKE_CXX_FLAGS "$ {CMAKE_CXX_FLAGS} -c") – Hustlion

관련 문제