This guide explains how to link QuickFIX into your application.
The easiest way to use QuickFIX in your project is with CMake's
find_package:
# In your CMakeLists.txt find_package(quickfix REQUIRED) add_executable(myapp main.cpp) target_link_libraries(myapp quickfix)
If QuickFIX is installed in a non-standard location, set
CMAKE_PREFIX_PATH to the installation directory.
When using Visual Studio without CMake, configure your project manually:
C:\quickfix\include)C:\quickfix\lib)quickfix.lib and ws2_32.libIf using SSL/TLS features, also add OpenSSL libraries:
libssl.liblibcrypto.libIf using database message stores, add the appropriate client library:
libmysql.liblibpq.libodbc32.lib-std=c++17 or -std=c++20-fexceptions (usually enabled by default)-O2 or -O3 for release buildsLink against QuickFIX and required system libraries:
g++ -std=c++17 myapp.cpp -o myapp -lquickfix -lpthread
g++ -std=c++17 myapp.cpp -o myapp -lquickfix -lpthread -lssl -lcrypto
g++ -std=c++17 myapp.cpp -o myapp -lquickfix -lpthread $(mysql_config --libs)
g++ -std=c++17 myapp.cpp -o myapp -lquickfix -lpthread -lpq
On macOS, use the system Clang compiler:
clang++ -std=c++17 myapp.cpp -o myapp -lquickfix -lpthread
Note: GNU ld is a one-pass linker. Place more
generally useful libraries (like -lpthread)
after more specific libraries on the command line.
In your C++ source files, include QuickFIX headers as follows:
#include "quickfix/Application.h" #include "quickfix/MessageCracker.h" #include "quickfix/Values.h" #include "quickfix/Mutex.h" // For specific FIX versions #include "quickfix/fix44/NewOrderSingle.h" #include "quickfix/fix44/ExecutionReport.h"
Here's a minimal example of a QuickFIX application:
#include "quickfix/Application.h"
#include "quickfix/MessageCracker.h"
#include "quickfix/SessionSettings.h"
#include "quickfix/FileStore.h"
#include "quickfix/FileLog.h"
#include "quickfix/SocketAcceptor.h"
class MyApplication : public FIX::Application
{
public:
void onCreate(const FIX::SessionID&) override {}
void onLogon(const FIX::SessionID&) override {}
void onLogout(const FIX::SessionID&) override {}
void toAdmin(FIX::Message&, const FIX::SessionID&) override {}
void toApp(FIX::Message&, const FIX::SessionID&) override {}
void fromAdmin(const FIX::Message&, const FIX::SessionID&) override {}
void fromApp(const FIX::Message&, const FIX::SessionID&) override {}
};
int main(int argc, char** argv)
{
FIX::SessionSettings settings("config.cfg");
MyApplication application;
FIX::FileStoreFactory storeFactory(settings);
FIX::FileLogFactory logFactory(settings);
FIX::SocketAcceptor acceptor(application, storeFactory, settings, logFactory);
acceptor.start();
// Wait for Ctrl-C or termination signal
acceptor.block();
acceptor.stop();
return 0;
}
See the examples/ directory for more complete applications.