1

I have a C library with a makefile that builds a shared library. Within my own CMAKE c++11 project, I target_link_libraries that shared library and include the header files. When building, during the linking process, I get the following error:

stdout: invalid version 5 (max 0)
error adding symbols: bad value 

Based on a similar issue described in this post: gcc Invalid version (max ) error adding symbols: Bad value, I attempted to use a version script to prevent any symbol collision. I added the commands to use the below script into the flags within the makefile for the library

CODEABI_1.0{
local:*;
};

However, this made no difference, and the error remains. This issue feels especially odd to me, as the referenced stackoverflow post and other similar posts all cover issues where the function is being defined within the library itself or within a linked static library, and that function is causing collisions. However, stdout is not being defined in the library, and is a part of the language.

As well, modifying the library itself is a last resort.

I'm not sure how to solve this issue, as all solutions I've been able to find deal with cases where there are library export conflicts, and not what I suppose are language conflicts. Any solutions would be greatly appreciated.

I am compiling this on ubuntu 20.04.2 using make: 4.2.1, gcc 9.3.0

To reproduce:

CMakeLists.txt relevant section from my project

add_custom_command(
    TARGET /*insert target*/
    COMMAND make
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/relevant/path
)

target_link_libraries(/*target*/ 
    /*other libs*/ 
    ${CMAKE_CURRENT_SOURCE_DIR}/relevant/path/to/file
)

target_include_directories(/*target*/
    ${CMAKE_CURRENT_SOURCE_DIR}/relevant/path
)

link to makefile for library: https://github.com/flightaware/dump1090/blob/master/Makefile

exampleHeader.h

void funct(void);

exampleC.c

#include "libraryHeader.h"

void funct(void){
   funcFromLibraryCall();
}

exampleCxxHeader.h

int main();

exampleCxx.cpp

extern "C"{
#include "exampleHeader.h"
}

int main(){
   funct();
}
Noah
  • 31
  • 1
  • 6
  • 1
    You should extract a [mcve] and include that in your question. You could also probably remove the dependency on `cmake` for building then. BTW: As a new user here, please take the [tour] and read [ask]. – Ulrich Eckhardt Jun 28 '21 at 18:15
  • I've added what I hope will be useful. There really isn't any code in my cmake project – Noah Jun 28 '21 at 18:49
  • 3
    The point about stripping `cmake` from the question is that it might be the cause of the problem. Trying to strip it from the [mcve] is supposed to answer that question. – Ulrich Eckhardt Jun 28 '21 at 19:01
  • The issue has been solved. While the file resulting from running make appeared to be a shared library and had a shared library extension, it was not in fact being built as a shared library. Added the -shared to the CFLAGS. Error was on my part for not ensuring the file type was actually correct. – Noah Jun 28 '21 at 20:00

1 Answers1

1

The issue has been solved. While the file resulting from running make appeared to be a shared library and had a shared library extension, it was not in fact being built as a shared library. Added the -shared to the CFLAGS. Error was on my part for not ensuring the file type was actually correct.

Noah
  • 31
  • 1
  • 6