linker

Linking errors while exporting std::vector from dll

邮差的信 提交于 2021-01-28 04:55:15
问题 I have a dll ( my_library.dll ) that exports a struct using __ declspec(dllexport) . Since this struct contains an std::vector<std::wstring> member , I've also exported functions for it like so: template class __declspec(dllexport) std::allocator<std::wstring>; template class __declspec(dllexport) std::vector<std::wstring>; Please note that I've defined macros such that dll exports above struct and vector when compiling and they are imported (via __declspec(dllimport)) when the dll is being

Add a static library (.a file) to an Android project with CMake, get “CMake Error: CMake can not determine linker language for target”

那年仲夏 提交于 2021-01-28 03:50:25
问题 I generate the static library from another Android project, so pretty sure they're useable. I got four .a files based on CPU architectures, one .h file which also has been tested. Now in new project, another .c file want to call the static library, i can't combine the two projects, the static libraries must be called in .a format. I got "CMake Error: CMake can not determine linker language for target", this is my CMakeLists.txt: add_library( mylib STATIC src/main/jniLibs/arm64-v8a/libmylib.a

Configure .ccls file for Vim

纵饮孤独 提交于 2021-01-28 03:13:08
问题 I have no idea what I am doing; I decided to use Vim as my only editor, I'm trying to set up autocompletion and syntax checking, so I need to configure a .ccls file in the root of my project (and I don't want to generate a compile_commands.json file so please don't tell me about it). But there is no detailed documentation whatsoever on .ccls because all it does is use compiler flags, which of course I don't know; I have started not too long ago in C++ and I don't know any CMake, I was used to

linker input file unused because linking not done - gcc

半世苍凉 提交于 2021-01-28 01:38:46
问题 I am a beginner in writing makefiles. I have a makefile something like this: PATH1 = /ref CC=gcc LINK = gcc INCLUDES = . INCLUDES += -I/PATH1/inc \ -I/$(PATH1)/abc/inc/ \ -I/$(PATH1)/def/inc/ all: src_file run: src_file src_file: $(CC) $(INCLUDES) -MM /ref/abcd.c -o $@ clean: rm -f *.o src_file If I do a make, I get the error: linker input file unused because linking not done. I read some similar posts in stackoverflow but couldn't get a solution. Could anybody please let me know what's wrong

Visual Studio Code clang error: linker command failed with exit code 1 on Mac

限于喜欢 提交于 2021-01-27 19:10:00
问题 I'm new to programming and wanted to try out VS Code for C++ development. I'm getting this error and I can't find a solution online how to fix: clang: error: linker command failed with exit code 1 (use -v to see invocation) The terminal process terminated with exit code: 1 I got a cpp file with the function definitions and a header file with the class and declarations in it and also a int main test file. So its a linker issue. VSC directed me to c_cpp_properties.json and I have no idea what

MinGW: Linking with -nostdlib produces invalid executable

≡放荡痞女 提交于 2021-01-27 16:42:29
问题 I've spent the last couple of hours trying to link a simple x86 assembly program without any of the CRT initialization code using MinGW. I want the executable to only contain the _main method listed below and a single import of the ExitProcess kernel function. Opening the various generated files in a disassembler reveals that _main is indeed the entry point and the import table contains an import of ExitProcess (without the name decorations) from KERNEL32.dll , however Windows won't load the

MinGW: Linking with -nostdlib produces invalid executable

白昼怎懂夜的黑 提交于 2021-01-27 16:35:52
问题 I've spent the last couple of hours trying to link a simple x86 assembly program without any of the CRT initialization code using MinGW. I want the executable to only contain the _main method listed below and a single import of the ExitProcess kernel function. Opening the various generated files in a disassembler reveals that _main is indeed the entry point and the import table contains an import of ExitProcess (without the name decorations) from KERNEL32.dll , however Windows won't load the

Is it legal C to declare a non-const variable 'const' externally?

时间秒杀一切 提交于 2021-01-27 14:26:44
问题 Say I have a file, window.h, which defines: extern const int window_width, window_height; I don't want anyone to change these variables, so they're const for all includers of window.h. However, is it legal to declare them non-const in the source file? // window.c int window_width, window_height; void onResizeWindow(int w, int h) { window_width = w; window_height = h; } This compiles without linker errors for me in Apple clang version 12.0.0 (clang-1200.0.22.7). But is it legal and well

Launching an App from a URL

 ̄綄美尐妖づ 提交于 2021-01-27 13:45:10
问题 I am attempting to get the Android application chooser to launch when a specific URL is clicked from within a registration e-mail. I have already looked at the below question and several others but I am still having no luck with this. Launching Android Application from link or email I have created my intent in the AndroidManifest.xml file as below (I've placed my website address where you see ".website.org"): <activity android:name=".MainActivity" android:configChanges="orientation|screenSize

gcc __attribute__((selectany)) alternative for linux?

拈花ヽ惹草 提交于 2021-01-27 13:23:42
问题 i would like to know if there is an alternative for __attribute__((selectany)) in linux ? i would like to define something like that: char * a[] = { "qwe", "zxc" }; in a header file and include it in many .c files which would be linked together. so the linker will see more than one definition of "a" and therefor will not link. i've read of this attribute (selectany), which will use only the first seen definition of "a", unfortunately it is only for ms windows. so the question is: is there an