简体   繁体   中英

CMake c++ library linking

I have Fortran target in CMake which relies on C++ libraries. What is portable way to include STDC++ into linking?

If you're linking with gfortran, add -lstdc++ , if linking with g++, you'll need -lgfortran . Either way, you'll need both of them, it's just that g++ automagically links with libstdc++, and gfortran automagically links with libgfortran.

There is no "portable" way as in cross-compiler or cross-"standard library vendor", because all the libraries are named differently.

Theoretically the STL is part of the C++, so you don't need to do anything in CMake to use STL. On other hand: if your C++ libraries have dependencies and their have CMake module (eg: FintQt4), CMake automatically handle the linking process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM