g++

how to create a shared object with high maintainability?

百般思念 提交于 2019-12-11 17:16:43
问题 I try to create a shared object for my C++ project with the purpose: every time I want to bring a new class, I recompile shared object only. below is test code: test.h : #if !defined(_TEST_) #define _TEST_ #include <string> #include <memory> class Test { private: public: Test() { } ~Test() { } virtual void show(const std::string &) = 0; }; #ifdef __cplusplus extern "C" { #endif // std::shared_ptr<Test> getObject(); #ifdef __cplusplus } #endif #endif // _TEST_ getObject.cpp : class TestSo

How to build and use GoogleTest shared library (.so) using g++ on Linux?

随声附和 提交于 2019-12-11 16:54:30
问题 NOTE it's not a duplicate of this question or this question. How to build Googletest from source using g++ into a shared library (.so)? I tried the steps described in Google Test's document on how to build a shared library, but linking the produced libgtest.so with my test programs didn't work - the linker throws tons of errors like: "gtest-all.cc:(.text+0x19b50): multiple definition of `testing::internal::HasNewFatalFailureHelper::~HasNewFatalFailureHelper()'libgtest.so:gtest-all.cc:(.text

basic unix ./ syntax

可紊 提交于 2019-12-11 16:28:42
问题 I'm compiling c++ programs from the OS X Terminal: > g++ a.cpp I then the run the program from the terminal: > ./a.out What does the ./ syntax mean? Is this somehow related to ./run ? 回答1: . means "the current directory", so ./a.out means "the file named a.out in the current directory". If you were to type simply a.out , without the ./ , then the system would look through the directories on the path ( $PATH ) to find the program, instead of looking in the current directory. 回答2: dot-slash is

Makefile g++ lrt problem. Cannot find lrt

陌路散爱 提交于 2019-12-11 15:51:28
问题 Here is my makefile. # The intuitive "all" target will be our default. .DEFAULT_GOAL := all # Component dir's to search and invoke make. # (Try preserving the order of directories) COM := src_dir1 src_dir2 src_dir3 PROJ_DIR = $(shell pwd) EXEC := anonymousforconfidentiality CC := g++ CFLAGS := -g3 LIBS = `pkg-config --cflags --libs glib-2.0 gio-unix-2.0 bluez protobuf lrt` .PHONY : clean compile link all all: | clean compile link link: $(eval $@_ALLOBJECTS := $(shell find . -name '*.o')) $(CC

g++ stops on undefined reference when using -O0

佐手、 提交于 2019-12-11 15:18:18
问题 I want to debug a program I wrote. Therefor I'd like to link it using "-g -O0". When I compile (using autotools Makefile) using make CXXFLAGS='-g -O0' I get some errors: libtool: link: g++ -O2 -g -O0 -I/opt/adolc-2.2.1/include -o oc_poly oc_poly-oc_poly.o oc_poly-oc_p2p.o -L/opt/ipopt-3.9.3/lib/coin -L/opt/ipopt-3.9.3/lib/coin/ThirdParty -L/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2 -L/usr/lib/i386-linux-gnu/gcc/i686- linux-gnu/4.5.2/../../.. -L/usr/lib/i386-linux-gnu /opt/ipopt-3.9.3

iostream, wifstream, and eclipse/g++ on windows

浪尽此生 提交于 2019-12-11 15:08:18
问题 I am using Eclipse on windows with the MinGW tool chain (g++, etc.). I have a program that I built on darwin that reads and writes to files using wifstream and wofstream. The program comiles and works find using eclipse on darwin (Mac)...no for my problem. When I move the code over to windows and try to build in using the MinGW tool chain and eclipse, I get a compile error on wifstream, wofstream, and wcout. Variables defined as wstring compile just fine. For example: wifstream inFile; inFile

Undefined reference to pthread_atfork`

∥☆過路亽.° 提交于 2019-12-11 14:53:52
问题 Using g++ version 4.9 in Ubuntu, when compiling a C++ source file named test.cpp that needs a shared library named libUtils.so (which in its turn needs Open MPI shared library, hence the parameter -Wl,-rpath-link,/home/dummy/openmpi/build/lib ) as follows: g++ test.cpp -lUtils -Wl,-rpath-link,/home/dummy/openmpi/build/lib An error is thrown /home/dummy/openmpi/build/lib/libopen-pal.so.20: undefined reference to pthread_atfork . I passed -pthread and -lpthread to g++ but none of these solved

How do I compile multiple cpp files into a single executable using g++ when the files are interdependent? [closed]

我与影子孤独终老i 提交于 2019-12-11 14:15:06
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'm making a calculator in c++ that accepts extremely high values. I made a class for the numbers, which I've defined in a header. My first cpp file contains basic functions like add, subtract, multiply, and divide (link). My second cpp file contains class definitions, which allow me to manipulate the number

OpenMP/gcc on macOS : gcc --without-multilib not available

允我心安 提交于 2019-12-11 14:14:41
问题 Last year I had a school project that used the OpenMP API for parallel computing. I installed gcc-6 --without-multilib with the Homebrew (brew) tool. It worked like charm. This year I had to make a new clean install of macOS High Sierra because of a software issue. Now I can't seem to install gcc without multilib with brew. When I type " brew info gcc ", I can see the different install flags, and --without-multilib in not in this list. (I tried gcc@5, @6 and @7). I tried installing gcc with

Floating point arithmetic varies between g++ and clang++?

て烟熏妆下的殇ゞ 提交于 2019-12-11 13:40:37
问题 I have come across a bug that seems to be platform dependent. I am getting different results for clang++ and g++ however only on my 32-Debian Machine. I was always under the impression that IEEE 754 was standardized and that all compilers that abide by the standard would have the same behavior. Please let me know if I am wrong, I am just very confused about this. Also, I realize that depending on floating point comparison is generally not a good idea. #define DEBUG(line) std::cout <<"\t\t" <<