linker

What every C++ developer should know about linking [closed]

独自空忆成欢 提交于 2020-01-01 03:29:26
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . The problem Information on how linking works in detail are scarce. Also IDEs hide the details of compilation which is a real pain when you have some linking related problem with your project. Usually C++ books

GNU linker: alternative to --version-script to list exported symbols at the command line?

风格不统一 提交于 2020-01-01 02:44:10
问题 On Linux with the GNU toolchain, I know how to control exported symbols from a shared library with a version script (gcc -Wl,--version-script=symbols.map), but I would like to list exported symbols on the command line instead. IOW, I would like the equivalent of link /EXPORT:foo from the MS toolchain. Is it possible ? EDIT: My question may not be very clearn: if I have a library libfoo.so, and I want to only export libraries foo1 and foo2, I can go create a version script foo.linux as follows

/usr/bin/ld: cannot find

落花浮王杯 提交于 2020-01-01 01:25:10
问题 I created a .so file and put it in the location /opt/lib and added this path to LD_LIBRARY_PATH now after this when I try to compile my main program with the following command: g++ -Wall -I/home/alwin/Development/Calculator/ main.cpp -lcalc -o calculator I get the following error: /usr/bin/ld: cannot find -lcalc collect2: ld returned 1 exit status Can someone help me with this. I created the shared library using the code blocks IDE 回答1: Add -L/opt/lib to your compiler parameters, this makes

Static and shared library symbol conflicts?

依然范特西╮ 提交于 2019-12-31 16:53:52
问题 I've got a project working on that's using FreeImage and openCV, currently we're using the jpeg support from both of these (I am working towards fixing that, but for now it's got to stay). Anyhow, FreeImage compiles libjpeg 7.0 into its static libraries, and openCV's highgui library links it in as a shared library (on my system, Ubuntu 9, I've got libjpeg 6.2 installed). They link into a final library that's used to link into various programs, java wrappers, etc. All of that works fine, no

How linker solves ambiguities when linking *.libs?

爱⌒轻易说出口 提交于 2019-12-31 05:29:28
问题 after very long long time spent with unresolved externals I found that VS2010 was linking wrong .lib file. Files were unfortunately named with same name. Folder with linked(unwanted) lib was set in project properties Folder with unlinked(wanted) lib was inherited from other property sheet Desired lib was newer date, undesired was very older. Linker chose the unwanted one (as above). What are the rules for linking libs? Shouldn't linker give at least warning on some ambiguity? edit: symbol is

Access PostgreSQL via C++-Interface (Linker error)

戏子无情 提交于 2019-12-31 05:20:55
问题 Im using visual studio 2012 Ultimate and PostgreSQL 9.2 64 bit. I set up a completely new project with the following settings: Additional includes folder: "C:\Program Files\PostgreSQL\9.2\include\" Additional libs folder: "C:\Program Files\PostgreSQL\9.2\lib\" Im linking against " libpq.lib ". My problem looks like that: #include <iostream> using namespace std; #include <libpq-fe.h> int main() { PGconn *psql = PQconnectdb("hostaddr = '127.0.0.1' port = '' dbname = 'fwaggle' user = 'fwaggle'

`cargo build` fails with linking error “link.exe failed: exit code: 325595”

一世执手 提交于 2019-12-31 05:19:26
问题 I have a Rust project that compiles okay on Linux, macOS, and Windows 10. I installed the following individual components on my Windows 7 computer today using the Visual Studio Installer: VC++ 2015.3 v14.00 (v140) toolset for desktop Windows Universal CRT SDK (Dependency) Windows 8.1 SDK (Dependency) After that, I installed Rust using a fresh rustup-init.exe from the official website. When I run cargo build on my Rust project on the Windows 7 computer, it fails with the following message:

Static member variable not global between executable and dll

大兔子大兔子 提交于 2019-12-31 05:12:25
问题 My knowledge is a bit fuzzy in terms of how linking a DLL works but I'm observing a change to a static member variable in an executable that doesn't change the same static member variable in a DLL. Here's the scenario I have: main.cpp is statically linked to mylib.lib. Within mylib.lib, I have the following class: // foo.h class Foo { public: static int m_global; Foo(); ~Foo(); }; and // foo.cpp #include "foo.h" int Foo::m_global = 5; I also have a DLL that links to mylib.lib with the

Linking error with cmake

懵懂的女人 提交于 2019-12-31 01:46:37
问题 I'm trying to understand why I get a linking error while compiling a project generated with CMake. The CMakeFiles.txt builds a static library for each folder of the project and then link all of them together in the following way: # root CMakeLists.txt add_subdirectory(subfolder1) add_subdirectory(subfolder2) add_subdirectory(...) add_executable(target ${SOURCES}) set(LIBRARIES LIB_FOO LIB_BAR ... ) target_link_libraries(target ${LIBRARIES} ) then in each subfolder I have a simple CMakeLists

Linking SDL2 and Clion

时光怂恿深爱的人放手 提交于 2019-12-31 01:46:21
问题 I have clion pointing to SDL2 directories and libs, but it fails to link the libraries when I try to build. Any ideas on how to fix this? CMakeLists: cmake_minimum_required(VERSION 3.3) project(cavestory_development) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -lSDL2") set(SDL2_INCLUDE_DIR C:/SDL2-2.0.3/i686-w64-mingw32/include/SDL2) set(SDL2_LIBRARY C:/SDL2-2.0.3/i686-w64-mingw32/lib) find_package(SDL2 REQUIRED) include_directories(${SDL2_INCLUDE_DIR}) set(SOURCE_FILES main.cpp) add