架构的未定义符号x86_64(2)

问题描述 投票:0回答:1

我从他们的官方GitHub存储库下载了QuickFix,并按照安装它的说明进行操作。

我做了这个步骤:

./bootstrap 
./configure  
make   
make check  
sudo make install

使用CLion我创建了一个新项目,并复制了“tradeclient”样本以开始使用。根据这个文档http://www.quickfixengine.org/quickfix/doc/html/project.html我想出了这个CMakeList:

cmake_minimum_required(VERSION 3.9)
project(quickFixClient)

set(CMAKE_CXX_STANDARD 11)

add_executable(quickFixClient tradeclient.cpp)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lquickfix")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lpthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lxml2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lz")

现在我正在尝试运行QuickFix“tradeclient”示例,但我收到此错误:

[ 50%] Linking CXX executable quickFixClient
Undefined symbols for architecture x86_64:
  "Application::run()", referenced from:
      _main in tradeclient.cpp.o
  "FIX::SessionSettings::SessionSettings(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      _main in tradeclient.cpp.o
  "vtable for Application", referenced from:
      _main in tradeclient.cpp.o
      Application::~Application() in tradeclient.cpp.o
  NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make[3]: *** [quickFixClient] Error 1
make[2]: *** [CMakeFiles/quickFixClient.dir/all] Error 2
make[1]: *** [CMakeFiles/quickFixClient.dir/rule] Error 2
make: *** [quickFixClient] Error 2

我使用的样本是:https://github.com/quickfix/quickfix/tree/master/examples/tradeclient

我的操作系统:macOS Sierra 10.12.6

处理器:64位

IDE使用的是:CLion

C ++编译器:g ++

一个类似的问题已经被问到:Undefined symbols for architecture x86_64 buiding on Netbeans,我试图补充:

set(CMAKE_CXX_COMPILER g++)
set(CMAKE_CXX_FLAGS -m64)

这给了我同样的错误

set(CMAKE_CXX_COMPILER g++)
set(CMAKE_CXX_FLAGS -m32)

这给了我几乎相同的错误,但有:

Undefined symbols for architecture i386:

我猜我没有正确安装,或者我没有链接一些必要的库。我做错了什么?

c++ quickfix
1个回答
0
投票

我使用错误的编译器。这解决了我的问题:

C编译器:/Applications/Xcode.app/Contents/Developer/usr/bin/gcc

C ++编译器:/Applications/Xcode.app/Contents/Developer/usr/bin/g++

© www.soinside.com 2019 - 2024. All rights reserved.