linker

Weird LNK2001 errors after migration to VS2019

限于喜欢 提交于 2020-08-10 18:57:50
问题 After moving my code from VS2017 to VS2019 I stumbled into strange linker behaviour -- it seems like it references objects from static library that it shouldn't have (which in turn refer to symbols that can't be resolved). Basically, I end up with this: 1>tools.lib(object_storage_azure.obj) : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl azure::storage::operation_context::operation_context(void)" (__imp_??0operation_context@storage@azure@@QEAA@XZ) 1>tools

SOLVED: relocation R_X86_64_32 against symbol `G8' can not be used when making a PIE object; recompile with -fPIE

↘锁芯ラ 提交于 2020-08-09 09:14:06
问题 I'm trying to compile lambda-expressions from scheme to llvm-ir and am having trouble with position independet code. source: (lambda (x) (display x)) target: bunch of declares... define %SObj* @G7() { entry: %calltmp = call %SObj* @closure_create(i64 ptrtoint (%SObj* (%SObj*)* @G8 to i64), %SObj* null) ret %SObj* %calltmp } define %SObj* @G8(%SObj* %G6) { entry: %calltmp = call %SObj* @display(%SObj* %G6) ret %SObj* %calltmp } define i32 @main(i32 %0, i8** %1) { entry: %calltmp = call %SObj*

Why is statically linking glibc discouraged?

蓝咒 提交于 2020-08-02 05:38:31
问题 Most of the sources online state that you can statically link glibc, but discourage from doing so; e.g. centos package repo: The glibc-static package contains the C library static libraries for -static linking. You don't need these, unless you link statically, which is highly discouraged. These sources rarely (or never) say why that would be a bad idea. 回答1: The reasons given in other answers are correct, but they are not the most important reason. The most important reason why glibc should

Why is statically linking glibc discouraged?

可紊 提交于 2020-08-02 05:37:27
问题 Most of the sources online state that you can statically link glibc, but discourage from doing so; e.g. centos package repo: The glibc-static package contains the C library static libraries for -static linking. You don't need these, unless you link statically, which is highly discouraged. These sources rarely (or never) say why that would be a bad idea. 回答1: The reasons given in other answers are correct, but they are not the most important reason. The most important reason why glibc should

Static/Dynamic Runtime Linking

混江龙づ霸主 提交于 2020-07-20 11:29:21
问题 What are the best practices for choosing the linking method in VC++? Can anything/everything be statically linked? On a dynamically linked project, is the relative/absolute location of the linked library important? What are the pros and cons ? added : I was mainly referring to lib files. Do they behave same as dll linking? 回答1: Dynamic links allow you to upgrade individual DLLs without recompiling your applications. That is why windows can be upgraded without your application being recompiled

Is there a way to know which compiler generated a static library?

别等时光非礼了梦想. 提交于 2020-07-17 10:14:33
问题 A third party provided me a static lib (.a) to link with on solaris station. I tried to compile with sunpro, and failed at link step. I suppose the issue is coming from the compiler I use (gcc instead?) or simply its version (as the std lib provided by the compiler could change from the version expected by the library AFAIK it could leads to errors at link step). How could I know which compiler was used to generate this lib? Is there some tools doing that? Some option in sunpro/gcc or

Calling C code from C++ in a CMake project. Undefined symbol. Have extern C

£可爱£侵袭症+ 提交于 2020-07-16 10:29:47
问题 I'm trying to build a CMake project that calls C code from C++, and I'm getting undefined symbols, even though I'm (AFAIK) properly using "extern C". CMakeLists.txt: cmake_minimum_required(VERSION 3.0) project(CTest LANGUAGES CXX) add_executable(test main.cpp lib.c) main.cpp: #include "lib.h" int main() { printit(); return 0; } lib.c: #include <stdio.h> #include "lib.h" int printit() { printf("Hello world\n"); return 0; } lib.h: extern "C" int printit(); That gives me an "undefined reference

Build OpenCV application with MSVS compiler in VSCode

孤街醉人 提交于 2020-07-14 11:49:44
问题 I'm trying to build my C++ project in VSCode. However, I'm experiencing link issues with OpenCV "error LNK2001: unresolved external symbol". I've build all the libraries I use with vcpkg. I build using this .bat file: @echo off if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" ( call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64 ) else ( call "C:\Program Files (x86)\Microsoft

Build OpenCV application with MSVS compiler in VSCode

折月煮酒 提交于 2020-07-14 11:48:13
问题 I'm trying to build my C++ project in VSCode. However, I'm experiencing link issues with OpenCV "error LNK2001: unresolved external symbol". I've build all the libraries I use with vcpkg. I build using this .bat file: @echo off if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" ( call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64 ) else ( call "C:\Program Files (x86)\Microsoft

How to use GTest with CMake ? Linkage problem when following Google's guide

本秂侑毒 提交于 2020-07-07 11:40:57
问题 I started to use boost test for my project, but I need to mock static methods, so I try to switch to GTest and GMock. I followed the really clear guide from google, and the CMakeLists seems to be doing its job : CMakeLists.txt cmake_minimum_required(VERSION 3.15) project(POC_V4) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) # Specifying we are using pthread for UNIX systems. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS} -pthread -Wall") find_package(OpenCV