Gcc -funit-at-the-time, which causes compilation to fail

we started linking our application with -libmysqlcppconn-static to support MySQL .

When we compile for debugging, everything is fine, but when we compile for release using gcc -O2 , we get errors.

We tracked the compiler option to be -funit-at-a-time . We get errors in the form:

libmysqlcppconn-static.a (mysql_connection.cpp.o): sql::mysql::MySQL_Savepoint::getSavepointId()': mysql_connection.cpp:(.text+0x8d): undefined reference to function sql::mysql::MySQL_Savepoint::getSavepointId()': mysql_connection.cpp:(.text+0x8d): undefined reference to std :: allocator :: allocator ( ) 'mysql_connection.cpp :(. text + 0x133): undefined reference to `std :: allocator :: ~ allocator ()'

We are currently working on this by including -fno-unit-at-a-time . Any understanding of how we can fix this will be appreciated.

+4
source share
1 answer

this may be because you are using gcc to compile the code. Try using g ++ to compile the file; otherwise, try using the following gcc -lstdc ++ file.cpp command

0
source

Source: https://habr.com/ru/post/1480120/


All Articles