boost/asio/ssl throwing "undefined reference" error - c++

I am new to boost and am trying to compile the most basic program that includes boost/asio/ssl.
I am working on ubuntu 13.10 64bit and installed the latest boost like this:
sudo apt-get install boost-all-dev
Here is the magnificent code I am trying to compile:
#include <stdio.h>
#include <boost/asio/ssl/stream.hpp>
int main(){
printf("Hi\n");
return 0;
}
I googled and googled and the few hints I was able to find suggests I use some boost library flags. So I did:
g++ my_prog.cpp -o my_prog.bin -lboost_system -lboost_thread -lpthread
and all the time I get the same error message (no matter how many -l i shove in):
/tmp/cci6dJdZ.o: In function `boost::asio::ssl::detail::openssl_init_base::do_init::do_init()':
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initC2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initC5Ev]+0x2c): undefined reference to `SSL_library_init'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initC2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initC5Ev]+0x31): undefined reference to `SSL_load_error_strings'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initC2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initC5Ev]+0x36): undefined reference to `OPENSSL_add_all_algorithms_noconf'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initC2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initC5Ev]+0x47): undefined reference to `CRYPTO_num_locks'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initC2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initC5Ev]+0xcc): undefined reference to `CRYPTO_set_locking_callback'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initC2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initC5Ev]+0xd6): undefined reference to `CRYPTO_set_id_callback'
/tmp/cci6dJdZ.o: In function `boost::asio::ssl::detail::openssl_init_base::do_init::~do_init()':
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initD2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initD5Ev]+0x13): undefined reference to `CRYPTO_set_id_callback'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initD2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initD5Ev]+0x1d): undefined reference to `CRYPTO_set_locking_callback'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initD2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initD5Ev]+0x22): undefined reference to `ERR_free_strings'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initD2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initD5Ev]+0x2c): undefined reference to `ERR_remove_state'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initD2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initD5Ev]+0x31): undefined reference to `EVP_cleanup'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initD2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initD5Ev]+0x36): undefined reference to `CRYPTO_cleanup_all_ex_data'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initD2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initD5Ev]+0x40): undefined reference to `CONF_modules_unload'
my_prog.cpp:(.text._ZN5boost4asio3ssl6detail17openssl_init_base7do_initD2Ev[_ZN5boost4asio3ssl6detail17openssl_init_base7do_initD5Ev]+0x45): undefined reference to `ENGINE_cleanup'
/tmp/cci6dJdZ.o: In function `boost::asio::error::detail::ssl_category::message(int) const':
my_prog.cpp:(.text._ZNK5boost4asio5error6detail12ssl_category7messageEi[_ZNK5boost4asio5error6detail12ssl_category7messageEi]+0x1d): undefined reference to `ERR_reason_error_string'
collect2: error: ld returned 1 exit status
Or in short: it complaining about missing symbols like:
undefined reference to `SSL_library_init'
or:
undefined reference to `ERR_reason_error_string'.
Another funny fact is that if I change the include:
#include <boost/asio/ssl/stream.hpp>
for example to
#include <boost/asio/ssl/stream_base.hpp>
it compiles just fine (even without -lboost_system and all others..).
I spent a whole day on this and still can't for the life of me figure this out.
Any ideas guys?

In vs2013, when I include <boost/asio/ssl.hpp> I see
unresolved external symbol _CONF_modules_upload
unresolved external symbol _ERR_reason_error_string
I solved those issues by adding
libcrypto32MD.lib
in Linker/Additional Dependencies

Related

C++: matplotlibcpp.h and Python.h linker error

I am finding trouble linking a library in C++.
I am trying for the first time to use "matplotlibcpp.h". This is a library that uses "Python.h"
My code is not using either of the libraries yet. It gives error just by including "matplotlibcpp". I am using python2.7 and Ubuntu 18.04 and am using Eclipse.
The code does not run if I include:
#include "matplotlibcpp.h" // programme runs if this is commented out. But I need it to add new features.
#include "Python.h"
I have added these paths in several futile attempts (they solved similar issues to other threads):
GCC C++ Compiler, include paths (-l)
/home/toni/Programs/Workspace/Libraries/matplotlib-cpp-master/
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy
/usr/include/python2.7
GCC C++ Linker, Library search path (-L)
/home/toni/Programs/Workspace/Libraries/matplotlib-cpp-master/
/usr/lib/python2.7/config-i386-linux-gnu
/usr/lib/python2.7
/usr/include/python2.7
The programme builds, but does not run:
Finished building: ../src/WindProfilesCoursera.cpp
Building target: WindProfilesCoursera
Invoking: GCC C++ Linker
g++ -L/home/toni/Programs/Workspace/Libraries/matplotlib-cpp-master/ -L/usr/lib/python2.7/config-i386-linux-gnu -L/usr/lib/python2.7 -L/usr/include/python2.7 -o "WindProfilesCoursera" ./src/WindProfilesCoursera.o
./src/WindProfilesCoursera.o: In function `_import_array':
/usr/include/python2.7/numpy/__multiarray_api.h:1456: undefined reference to `PyImport_ImportModule'
makefile:45: recipe for target 'WindProfilesCoursera' failed
/usr/include/python2.7/numpy/__multiarray_api.h:1460: undefined reference to `PyExc_ImportError'
/usr/include/python2.7/numpy/__multiarray_api.h:1460: undefined reference to `PyErr_SetString'
/usr/include/python2.7/numpy/__multiarray_api.h:1463: undefined reference to `PyObject_GetAttrString'
/usr/include/python2.7/numpy/__multiarray_api.h:1466: undefined reference to `PyExc_AttributeError'
/usr/include/python2.7/numpy/__multiarray_api.h:1466: undefined reference to `PyErr_SetString'
/usr/include/python2.7/numpy/__multiarray_api.h:1478: undefined reference to `PyCObject_Type'
/usr/include/python2.7/numpy/__multiarray_api.h:1479: undefined reference to `PyExc_RuntimeError'
/usr/include/python2.7/numpy/__multiarray_api.h:1479: undefined reference to `PyErr_SetString'
/usr/include/python2.7/numpy/__multiarray_api.h:1483: undefined reference to `PyCObject_AsVoidPtr'
/usr/include/python2.7/numpy/__multiarray_api.h:1487: undefined reference to `PyExc_RuntimeError'
/usr/include/python2.7/numpy/__multiarray_api.h:1487: undefined reference to `PyErr_SetString'
/usr/include/python2.7/numpy/__multiarray_api.h:1493: undefined reference to `PyExc_RuntimeError'
/usr/include/python2.7/numpy/__multiarray_api.h:1493: undefined reference to `PyErr_Format'
/usr/include/python2.7/numpy/__multiarray_api.h:1499: undefined reference to `PyExc_RuntimeError'
/usr/include/python2.7/numpy/__multiarray_api.h:1499: undefined reference to `PyErr_Format'
/usr/include/python2.7/numpy/__multiarray_api.h:1511: undefined reference to `PyExc_RuntimeError'
/usr/include/python2.7/numpy/__multiarray_api.h:1511: undefined reference to `PyErr_Format'
/usr/include/python2.7/numpy/__multiarray_api.h:1522: undefined reference to `PyExc_RuntimeError'
/usr/include/python2.7/numpy/__multiarray_api.h:1522: undefined reference to `PyErr_Format'
collect2: error: ld returned 1 exit status
make: *** [WindProfilesCoursera] Error 1
"make all" terminated with exit code 2. Build might be incomplete.
20:35:04 Build Failed. 22 errors, 1 warnings. (took 2s.454ms)

Programming with no dependencies

I'm trying to make a PE (Portable Executable which will work with Windows XP+ and which has no dependencies.
I found this guide quite interesting http://www.catch22.net/tuts/reducing-executable-size
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
extern "C" int __cdecl __purecall(void)
{
return 0;
}
extern "C" int __cdecl main();
extern "C" int __cdecl mainCRTStartup( void )
{
int mainret;
mainret = main();
ExitProcess(mainret);
}
And I compile it with
g++ -Wall -o2 -s -nodefaultlibs main.cpp -o test.exe
And it's giving me a bunch of errors: http://i.stack.imgur.com/fIFoD.png
C:\Users\Main.cpp\Desktop\crt>g++ -Wall -o2 -s -nodefaultlibs -lkernel32 main.cpp -o test.exe
C:\Users\Main.cpp\AppData\Local\Temp\cczgOKUx.o:main.cpp:(.text+0x1c): multiple definition of `mainCRTStartup'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x280): first defined here
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x5): undefined reference to `__dyn_tls_init_callback'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x39): undefined reference to `__cpu_features_init'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x3e): undefined reference to `_fpreset'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x4b): undefined reference to `_CRT_glob'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x73): undefined reference to `__getmainargs'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x78): undefined reference to `_CRT_fmode'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x82): undefined reference to `_imp___iob'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x87): undefined reference to `_fmode'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x96): undefined reference to `_setmode'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x9b): undefined reference to `_CRT_fmode'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0xaa): undefined reference to `_setmode'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0xaf): undefined reference to `_CRT_fmode'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0xbe): undefined reference to `_setmode'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0xc3): undefined reference to `__p__fmode'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0xc9): undefined reference to `_fmode'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0xd0): undefined reference to `_pei386_runtime_relocator'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0xd8): undefined reference to `__main'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0xdd): undefined reference to `__p__environ'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x100): undefined reference to `_cexit'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x13f): undefined reference to `signal'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x195): undefined reference to `signal'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x1d0): undefined reference to `signal'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x217): undefined reference to `signal'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x233): undefined reference to `signal'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x250): more undefined references to `signal' follow
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x266): undefined reference to `_fpreset'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x28c): undefined reference to `_imp____set_app_type'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x2ac): undefined reference to `_imp____set_app_type'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x2c1): undefined reference to `_imp__atexit'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o:crt1.c:(.text+0x2d1): undefined reference to `_imp___onexit'
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../../mingw32/bin/ld.exe: C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../crt2.o: bad reloc address 0x20 in section `.eh_frame'
collect2.exe: error: ld returned 1 exit status
As far as I understood, my mainCRTStartup is interfering with another mainCRTStartup which my compiler is adding.
I'm using TDM-GCC on Windows.
After the suggestion to use -nostdlib instead of -nodefaultlibs I'm getting much less errors.
The ones I currently have are
C:\Users\Main.cpp\AppData\Local\Temp\ccMYa3VN.o:main.cpp:(.text+0x11): undefined reference to `__main'
C:\Users\Main.cpp\AppData\Local\Temp\ccMYa3VN.o:main.cpp:(.text+0x31): undefined reference to `ExitProcess#4'
GCC use some internal subroutines, contained in libgcc.a, that cannot be excluded.
See https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/Link-Options.html#Link-Options:
One of the standard libraries bypassed by -nostdlib and -nodefaultlibs
is libgcc.a, a library of internal subroutines which GCC uses to
overcome shortcomings of particular machines, or special needs for
some languages. (See Interfacing to GCC Output, for more discussion of
libgcc.a.) In most cases, you need libgcc.a even when you want to
avoid other standard libraries. In other words, when you specify
-nostdlib or -nodefaultlibs you should usually specify -lgcc as well. This ensures that you have no unresolved references to internal GCC
library subroutines.
P.S. The functions ExitProcess and SetUnhandledExceptionFilter are from kernel32.lib that you must include in linker stream. You can reduce libraries, but can't omit system and OS libraries.

How can do I link libevent that has been configured to have a different prefix?

I am trying to link libevent using g++ but am having trouble since I set libevent's install directory with the --prefix flag when configuring. To install libevent I downloaded the latest source, extracted it and ran the following commands in the directory
./configure --prefix=/home/tom/local --disable-shared && make
make install
After running these commands libevent successfully installs to the /home/tom/local folder. Now to test that I can use libevent I have downloaded the sample rot13 server with libevent that can be found towards the bottom of: http://www.wangafu.net/~nickm/libevent-book/01_intro.html
To compile I run the following command:
g++ -I=/home/tom/local/include rot13server.cpp -L/home/tom/local/lib
But I get the following compilation errors:
/tmp/cctwJY4k.o: In function `alloc_fd_state(event_base*, int)':
libevent.cc:(.text+0x9b): undefined reference to `event_new'
libevent.cc:(.text+0xec): undefined reference to `event_new'
libevent.cc:(.text+0x11a): undefined reference to `event_free'
/tmp/cctwJY4k.o: In function `free_fd_state(fd_state*)':
libevent.cc:(.text+0x1b6): undefined reference to `event_free'
libevent.cc:(.text+0x1c9): undefined reference to `event_free'
/tmp/cctwJY4k.o: In function `do_read(int, short, void*)':
libevent.cc:(.text+0x310): undefined reference to `event_add'
/tmp/cctwJY4k.o: In function `do_write(int, short, void*)':
libevent.cc:(.text+0x4da): undefined reference to `event_del'
/tmp/cctwJY4k.o: In function `do_accept(int, short, void*)':
libevent.cc:(.text+0x564): undefined reference to `evutil_make_socket_nonblocking'
libevent.cc:(.text+0x5da): undefined reference to `event_add'
/tmp/cctwJY4k.o: In function `run()':
libevent.cc:(.text+0x5f3): undefined reference to `event_base_new'
libevent.cc:(.text+0x63f): undefined reference to `evutil_make_socket_nonblocking'
libevent.cc:(.text+0x6d2): undefined reference to `event_new'
libevent.cc:(.text+0x6e7): undefined reference to `event_add'
libevent.cc:(.text+0x6f3): undefined reference to `event_base_dispatch'
collect2: error: ld returned 1 exit status
It seems like the compiler is finding the include files but not the object files.
I also tried configuring libevent without the --disable-shared option and then exported /home/tom/local/lib to the LD_LIBRARY_PATH but I still get the same error with the compile command:
g++ -I=/home/tom/local/include rot13server.cpp
Can anyone tell me what I am doing wrong?
Thanks
Can anyone tell me what I am doing wrong?
Just about everything.
The -I=/home/tom/local/include tells GCC to look in =/home/tom/local/include directory, which is unlikely to exist.
You want:
g++ -I/home/tom/local/include rot13server.cpp -c
g++ -L/home/tom/local/lib rot13server.o -levent -o rot13server

Problems compiling windows 64 program on linux - headers

I have been trying to compile a windows 64 program, MSVAR1.3, on linux and have had problems with Linux and the headers that the program calls. The program calls for:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#ifdef __BORLANDC__
#include <float.h>
If I run the compile (using gcc in linux) and try to use the -I flag to tell it where the headers are, it doesn't get any better than if I run the compilation without headers at all. I have included some of the output below (I get almost 300 lines of unrecognized variables).
I have also tried running it with an -lm flag for the math library and this reduces the unrecognized errors, but if there are flags relating to libraries for the other headers, I haven't been able to find them. PLEASE HELP!!!!
(Errors from running using the -I flag:)
gcc msvar1.3.c -o msvar1.3 -lm/tmp/ccpZIkC1.o: In function `main':
msvar1.3.c:(.text+0x38): undefined reference to `opengfsr'
msvar1.3.c:(.text+0x927): undefined reference to `gfsr8'
msvar1.3.c:(.text+0x94c): undefined reference to `gfsr8'
msvar1.3.c:(.text+0x971): undefined reference to `gfsr8'
msvar1.3.c:(.text+0x9a2): undefined reference to `disrand'
msvar1.3.c:(.text+0x111a): undefined reference to `printerr'
msvar1.3.c:(.text+0x1809): undefined reference to `printerr'
msvar1.3.c:(.text+0x1ad2): undefined reference to `printerr'
msvar1.3.c:(.text+0x1be6): undefined reference to `gfsr8'
msvar1.3.c:(.text+0x2773): undefined reference to `closegfsr'
msvar1.3.c:(.text+0x2791): undefined reference to `closegfsr'
/tmp/ccpZIkC1.o: In function `treesummary':
msvar1.3.c:(.text+0x2808): undefined reference to `printerr'
/tmp/ccpZIkC1.o: In function `read_params':
msvar1.3.c:(.text+0x2b1f): undefined reference to `printerr'
msvar1.3.c:(.text+0x2b64): undefined reference to `printerr'
msvar1.3.c:(.text+0x2b72): undefined reference to `intrand'
msvar1.3.c:(.text+0x2bb7): undefined reference to `printerr'
msvar1.3.c:(.text+0x3000): undefined reference to `printerr'
msvar1.3.c:(.text+0x3063): undefined reference to `printerr'
msvar1.3.c:(.text+0x3077): undefined reference to `printerr'
/tmp/ccpZIkC1.o: In function `choosepar':
msvar1.3.c:(.text+0x36fb): undefined reference to `gfsr8'
msvar1.3.c:(.text+0x374b): undefined reference to `gfsr4'
msvar1.3.c:(.text+0x3799): undefined reference to `gfsr4'
msvar1.3.c:(.text+0x37b8): undefined reference to `norm4'
msvar1.3.c:(.text+0x37e5): undefined reference to `gfsr4'
msvar1.3.c:(.text+0x3826): undefined reference to `norm4'
msvar1.3.c:(.text+0x3853): undefined reference to `gfsr4'
msvar1.3.c:(.text+0x3894): undefined reference to `norm4'
msvar1.3.c:(.text+0x38f7): undefined reference to `norm4'
"undefined reference" errors are not from missing headers - they're linker errors indicating you don't link with an object, nor have a -l (minus ell) flag specifying a library, that exports these symbols. The headers only constitute a promise that variables and out-of-lines function matching the header declarations will be found in an object/library you provide at link time - you're breaking that promise.
You need to either find the libraries containing those symbols, or find the source and compile them.
I compiled msvar1.3 with command:
gcc -o msvar1.3 myutil.c msvar1.3.c -lm

What libs should I include when compiling with mingw?

I'm trying to compile the MAPI example for windows, using MinGW compiler (on linux).
I tried straightforward approach:
$ i686-w64-mingw32-g++ swpmain.h swpmain.cpp swap.h swap.cpp
//
// bunch of warnings here...
//
/tmp/ccggw42y.o:swap.cpp:(.text+0x2f9): undefined reference to `_MAPIInitialize#4'
/tmp/ccggw42y.o:swap.cpp:(.text+0x31c): undefined reference to `_MAPIAllocateBuffer#8'
/tmp/ccggw42y.o:swap.cpp:(.text+0x350): undefined reference to `_MAPIUninitialize#0'
/tmp/ccggw42y.o:swap.cpp:(.text+0x41a): undefined reference to `_MAPIAllocateBuffer#8'
/tmp/ccggw42y.o:swap.cpp:(.text+0x445): undefined reference to `_MAPIAllocateBuffer#8'
/tmp/ccggw42y.o:swap.cpp:(.text+0x65f): undefined reference to `_MAPIAllocateBuffer#8'
/tmp/ccggw42y.o:swap.cpp:(.text+0xf5b): undefined reference to `_MAPIFreeBuffer#4'
/tmp/ccggw42y.o:swap.cpp:(.text+0xf6c): undefined reference to `_MAPIFreeBuffer#4'
/tmp/ccggw42y.o:swap.cpp:(.text+0x1782): undefined reference to `_MAPIFreeBuffer#4'
collect2: ld returned 1 exit status
ld error hints that I forgot to include some library - but I can't figure out which one. I tried searching files in usr/, but I only found mapi.h and mapix.h headers - no libraries.
What am I doing wrong here?