天道酬勤,学无止境

linker

How the code run when exist override ambigous function?

I can not fully understand the code result when exist override ambigous function. I have a libray libMy, which contains two class A and B. The code shows as follows // A.h #ifndef included_A_h #define included_A_h class A { public: void print(); }; #endif // A.cpp #include "A.h" #include <iostream> void A::print() { std::cout << "A from library" << std::endl; } // B.h #ifndef included_B_h #define included_B_h class A; class B { public: void printA(A &a); }; #endif // B.cpp #include "B.h" #include "A.h" void B::printA(A &a) { a.print(); } I have two main function, they can generate two

2021-06-21 11:24:41    分类:问答    c++   compilation   linker   g++   ambiguous

Enabling link-time optimizations causes a linker error?

I have code which compiles and links fine. I'm now trying to enable link-time optimizations, but adding -flto to my compiler and linker flags is causing a linker error: /usr/local/lib/libboost_thread.a(thread.o): \ In function `void boost::throw_exception<boost::bad_lexical_cast>(boost::bad_lexical_cast const&)': thread.cpp:(.text._ZN5boost15throw_exceptionINS_16bad_lexical_castEEEvRKT_[_ZN5boost15throw_exceptionINS_16bad_lexical_castEEEvRKT_]+0x124): \ undefined reference to `vtable for boost::bad_lexical_cast' The only flag I've added is -flto. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS

2021-06-21 10:55:48    分类:问答    c++   gcc   linker   lto

GLEW_APPLE_GLX 在构建 GLEW 时导致链接错误(GLEW_APPLE_GLX Causes Linking Error When Building GLEW)

问题 我在尝试解决我的另一个问题时在__glewX* ,关于 Mac 缺少__glewX*符号,并发现它们由GLEW_APPLE_GLX保护。 当我尝试从定义了该标志的源代码构建 GLEW 时,我得到了未定义的符号(例如_glXGetClientString东西)。 链接 X11 ( -lX11 ) 没有帮助。 问题:假设定义GLEW_APPLE_GLX确实有意义,我该如何修复构建? 回答1 在构建使用 X Server (XQuartz) 而不是使用 CGL 的应用程序时,您还需要添加-lGL 。 通常,在 OS X 上构建 GL 软件时,您使用OpenGL.framework ( -framework OpenGL ),这会为您提供 OpenGL 和 CGL/AGL 功能,但会-framework OpenGL GLX。 您还应该<OpenGL/gl.h>对<OpenGL/gl.h>类的任何包含并使用<GL/gl.h>代替,因为这将指向/usr/X11R6/include/GL/...而不是 OpenGL 框架标头.

2021-06-21 10:45:21    分类:技术分享    opengl   linker   x11   glew

Visual Studio 2015: v120 vs v140?

FYI: Win10, x64 I started trying out Visual Studio 2015 today, and after figuring out how to get the C/C++ parts running I tried to load up a big personal project that uses the unofficial glsdk. I tried to build and got linker errors. It complained about unresolved external symbols being referenced in freeglutD.lib, glloadD.lib, and glutil.lib. It also complained about _MSC_VER mismatches in my own files. I did some research online, messed around with 2013 and compiler versions (project properties -> General -> Platform Toolset)) - v120 for 2013 and v140 for 2015 - and was able to rebuild

2021-06-21 10:39:17    分类:问答    c++   compiler-errors   linker   visual-studio-2015   freeglut

Ubuntu 11.10 linking perftools library

I can't get gcc in Ubuntu 11.10 to properly link in the google perftools -lprofiler. The problem seems to be that the linker discards libraries which are not directly used in a program. An example will help. Let's call this main.cpp: #include <math.h> int main() { double value; for (int i=0; i < 1000000; i++) { for (int j=0; j < 1000; j++) value = sqrt(100.9); } return 0; } Compile using: g++ -c main.cpp -o main.o g++ main.o -o main -lm -lprofiler Check the executable using ldd ./main: linux-vdso.so.1 => (0x00007fff5a9ff000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f32bc1c9000)

2021-06-21 09:52:53    分类:问答    c++   c   ubuntu   linker

What is “Alignment” field in binary formats? Why is it needed?

In ELF file format we have an Alignment field in Segment Header Table aka Program Header Table. In case of Windows PE file format they take it to next level the Sections have two alignment values, one within the disk file and the other in memory. The PE file header specifies both of these values. I didn't understand a thing about this alignment. What do we need it for? How & Where is it used? Again, I don't know what is alignment in binary file format context but why do we need it?

2021-06-21 09:23:37    分类:问答    linker   loader   binaryfiles   elf   portable-executable

Undefined Python references in g++

I am using the following command: g++ -L/usr/lib/panda3d -L/usr/lib -o "panda3dplayground" ./main.o -lpython2.7 -lp3pystub -lp3framework -lpandafx -lp3pystub -lpandaexpress -lpanda -lp3framework -lp3direct And I am getting the following errors: /usr/lib/panda3d/libpanda.so: undefined reference to `PyObject_Cmp' /usr/lib/panda3d/libpanda.so: undefined reference to `PyUnicodeUCS4_FromWideChar' /usr/lib/panda3d/libpanda.so: undefined reference to `PyDict_SetItem' /usr/lib/panda3d/libpanda.so: undefined reference to `PyExc_ValueError' /usr/lib/panda3d/libpanda.so: undefined reference to `PyDict

2021-06-15 12:54:11    分类:问答    c++   linker   g++

Android NDK Cmake Linking .a (Static) Libs

I am using Android Studio 2.2.2 with cmake and Android NDK. I have a problem linking .a library (Static lib). Here is my cmake: # Sets the minimum version of CMake required to build the native # library. You should either keep the default value or only pass a # value of 3.4.0 or lower. cmake_minimum_required(VERSION 3.4.1) set(CMAKE_VERBOSE_MAKEFILE on) # Creates and names a library, sets it as either STATIC # or SHARED, and provides the relative paths to its source code. # You can define multiple libraries, and CMake builds it for you. # Gradle automatically packages shared libraries with

2021-06-15 11:49:31    分类:问答    android   android-ndk   linker   cmake   linker-errors

How to set text in a UITextView as a link to a URL

I have some text in a UITextView, that I would like to have show as blue, and serve as a link to a website. How do I do that in interface builder?

2021-06-15 11:17:03    分类:问答    iphone   url   interface-builder   linker

how to avoid “already defined error” in C++

I am gettings these type of errors in a MFC VS6 project while linking the application: msvcrt.lib(MSVCRT.dll) : error LNK2005: _atoi already defined in LIBC.lib(atox.obj) I know what it means (a function exists in 2 different libraries); to solve it I should have to exclude one of the 2 libraries (msvcrt.lib or libc.lib). But if I do this there are all kinds of unresolved external errors. So I would like to keep using both libraries. Is there any way to tell the linker that I want to use the _atoi function in libc.lib and not in msvcrt.lib (or the other way around)? Any help or direction would

2021-06-15 09:59:08    分类:问答    c++   linker   visual-studio-6