RedFantom / masterkeys-linux

MasterKeys SDK for Linux
GNU General Public License v3.0
20 stars 4 forks source link

Unable to compile: multiple definition of `LIBMK_MODEL_STRINGS' #6

Closed antlampas closed 3 years ago

antlampas commented 3 years ago

Hi @RedFantom, I'm on Fedora 33 and i got that compile error, both from github sources and pip sources. This is the full output of setup.py:

ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wvfldzt7/masterkeys/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wvfldzt7/masterkeys/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4wfkhqpw/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/masterkeys                                                                                                  
         cwd: /tmp/pip-install-wvfldzt7/masterkeys/                                                                                                                                                                                                                                                                        
    Complete output (112 lines):                                                                                                                                                                                                                                                                                           

    --------------------------------------------------------------------------------                                                                                                                                                                                                                                       
    -- Trying "Ninja" generator                                                                                                                                                                                                                                                                                            
    --------------------------------                                                                                                                                                                                                                                                                                       
    ---------------------------                                                                                                                                                                                                                                                                                            
    ----------------------                                                                                                                                                                                                                                                                                                 
    -----------------                                                                                                                                                                                                                                                                                                      
    ------------                                                                                                                                                                                                                                                                                                           
    -------                                                                                                                                                                                                                                                                                                                
    --                                                                                                                                                                                                                                                                                                                     
    Not searching for unused variables given on the command line.                                                                                                                                                                                                                                                          
    -- The C compiler identification is GNU 10.2.1                                                                                                                                                                                                                                                                         
    -- Detecting C compiler ABI info                                                                                                                                                                                                                                                                                       
    -- Detecting C compiler ABI info - done                                                                                                                                                                                                                                                                                
    -- Check for working C compiler: /usr/bin/cc - skipped                                                                                                                                                                                                                                                                 
    -- Detecting C compile features                                                                                                                                                                                                                                                                                        
    -- Detecting C compile features - done                                                                                                                                                                                                                                                                                 
    -- The CXX compiler identification is GNU 10.2.1                                                                                                                                                                                                                                                                       
    -- Detecting CXX compiler ABI info                                                                                                                                                                                                                                                                                     
    -- Detecting CXX compiler ABI info - done                                                                                                                                                                                                                                                                              
    -- Check for working CXX compiler: /usr/bin/c++ - skipped                                                                                                                                                                                                                                                              
    -- Detecting CXX compile features                                                                                                                                                                                                                                                                                      
    -- Detecting CXX compile features - done                                                                                                                                                                                                                                                                               
    -- Configuring done                                                                                                                                                                                                                                                                                                    
    -- Generating done                                                                                                                                                                                                                                                                                                     
    -- Build files have been written to: /tmp/pip-install-wvfldzt7/masterkeys/_cmake_test_compile/build                                                                                                                                                                                                                    
    --                                                                                                                                                                                                                                                                                                                     
    -------                                                                                                                                                                                                                                                                                                                
    ------------                                                                                                                                                                                                                                                                                                           
    -----------------                                                                                                                                                                                                                                                                                                      
    ----------------------                                                                                                                                                                                                                                                                                                 
    ---------------------------                                                                                                                                                                                                                                                                                            
    --------------------------------                                                                                                                                                                                                                                                                                       
    -- Trying "Ninja" generator - success                                                                                                                                                                                                                                                                                  
    --------------------------------------------------------------------------------                                                                                                                                                                                                                                       

    Configuring Project                                                                                                                                                                                                                                                                                                    
      Working directory:                                                                                                                                                                                                                                                                                                   
        /tmp/pip-install-wvfldzt7/masterkeys/_skbuild/linux-x86_64-3.9/cmake-build                                                                                                                                                                                                                                         
      Command:
        cmake /tmp/pip-install-wvfldzt7/masterkeys -G Ninja -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-install-wvfldzt7/masterkeys/_skbuild/linux-x86_64-3.9/cmake-install -DPYTHON_EXECUTABLE:FILEPATH=/usr/bin/python -DPYTHON_VERSION_STRING:STRING=3.9.0 -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.9 -DPYTHON_LIBRARY:FILEPATH=/usr/lib64/libpython3.9.so -DSKBUILD:BOOL=TRUE -DCMAKE_MODULE_PATH:PATH=/usr/local/lib/python3.9/site-packages/skbuild/resources/cmake -DCMAKE_BUILD_TYPE:STRING=Release

    CMake Warning (dev) in CMakeLists.txt:
      No project() command is present.  The top-level CMakeLists.txt file must
      contain a literal, direct call to the project() command.  Add a line of
      code such as

        project(ProjectName)

      near the top of the file, but after cmake_minimum_required().

      CMake is pretending there is a "project(Project)" command on the first
      line.
    This warning is for project developers.  Use -Wno-dev to suppress it.

    -- The C compiler identification is GNU 10.2.1
    -- The CXX compiler identification is GNU 10.2.1
    -- Detecting C compiler ABI info
    -- Detecting C compiler ABI info - done
    -- Check for working C compiler: /usr/bin/cc - skipped
    -- Detecting C compile features
    -- Detecting C compile features - done
    -- Detecting CXX compiler ABI info
    -- Detecting CXX compiler ABI info - done
    -- Check for working CXX compiler: /usr/bin/c++ - skipped
    -- Detecting CXX compile features
    -- Detecting CXX compile features - done
    -- Found PythonInterp: /usr/bin/python (found version "3.9")
    -- Found PythonLibs: /usr/lib64/libpython3.9.so (found version "3.9.0")
    -- Performing Test Weak Link MODULE -> SHARED (gnu_ld_ignore) - Success
    _modinit_prefix:PyInit_
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /tmp/pip-install-wvfldzt7/masterkeys/_skbuild/linux-x86_64-3.9/cmake-build
    [1/7] Building C object CMakeFiles/masterkeys.dir/masterkeys/masterkeys.c.o
    In file included from /usr/include/python3.9/Python.h:85,
                     from ../../../masterkeys/masterkeys.c:14:
    /usr/include/python3.9/pytime.h:153:60: warning: ‘struct timespec’ declared inside parameter list will not be visible outside of this definition or declaration
      153 | PyAPI_FUNC(int) _PyTime_FromTimespec(_PyTime_t *tp, struct timespec *ts);
          |                                                            ^~~~~~~~
    /usr/include/python3.9/pytime.h:158:56: warning: ‘struct timespec’ declared inside parameter list will not be visible outside of this definition or declaration
      158 | PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts);
          |                                                        ^~~~~~~~
    In file included from ../../../masterkeys/masterkeys.c:12:
    ../../../masterkeys/../libmk/libmk.h:147:13: warning: array ‘LIBMK_MODEL_STRINGS’ assumed to have one element
      147 | const char* LIBMK_MODEL_STRINGS[];
          |             ^~~~~~~~~~~~~~~~~~~
    [2/7] Building C object CMakeFiles/masterkeys.dir/libmk/libmk.c.o
    [3/7] Building C object CMakeFiles/mk.dir/libmk/libmk.c.o
    [4/7] Linking C shared library mk.so.0.1.0
    [5/7] Creating library symlink mk.so
    [6/7] Linking C shared module masterkeys.cpython-39-x86_64-linux-gnu.so
    FAILED: masterkeys.cpython-39-x86_64-linux-gnu.so
    : && /usr/bin/cc -fPIC -std=c99 -O2 -DNDEBUG  -Wl,--unresolved-symbols=ignore-all -Wl,--version-script="/tmp/pip-install-wvfldzt7/masterkeys/_skbuild/linux-x86_64-3.9/cmake-build/CMakeFiles/masterkeys-version-script.map" -shared  -o masterkeys.cpython-39-x86_64-linux-gnu.so CMakeFiles/masterkeys.dir/masterkeys/masterkeys.c.o CMakeFiles/masterkeys.dir/libmk/libmk.c.o  -Wl,-rpath,/tmp/pip-install-wvfldzt7/masterkeys/_skbuild/linux-x86_64-3.9/cmake-build:  /usr/lib64/libpython3.9.so  mk.so.0.1.0  -lusb-1.0 && :
    /usr/bin/ld: CMakeFiles/masterkeys.dir/libmk/libmk.c.o:(.data.rel.local+0x0): multiple definition of `LIBMK_MODEL_STRINGS'; CMakeFiles/masterkeys.dir/masterkeys/masterkeys.c.o:(.bss+0x0): first defined here
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    Traceback (most recent call last):
      File "/usr/local/lib/python3.9/site-packages/skbuild/setuptools_wrap.py", line 589, in setup
        cmkr.make(make_args, env=env)
      File "/usr/local/lib/python3.9/site-packages/skbuild/cmaker.py", line 496, in make
        raise SKBuildError(

    An error occurred while building with CMake.
      Command:
        cmake --build . --target install --config Release --
      Source directory:
        /tmp/pip-install-wvfldzt7/masterkeys
      Working directory:
        /tmp/pip-install-wvfldzt7/masterkeys/_skbuild/linux-x86_64-3.9/cmake-build
    Please see CMake's output for more information.
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wvfldzt7/masterkeys/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wvfldzt7/masterkeys/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4wfkhqpw/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/masterkeys Check the logs for full command output.

It says that first definition is in materkeys.c.o, so i presume is the objcect file from masterkeys.c, but actually there isn't that definition in there... no clue...

RedFantom commented 3 years ago

Thank you for opening this issue! I verified your problem in a Virtual Machine with Fedora 33. While I am unable to test what the actual code is doing now, as I am away from my keyboard, I did fix the issue.

Fedora 33 comes with GCC 10.2.1, a version newer than 9.3.0 which I always work with. This likely caused the issue as newer compilers can be more strict about some things.

Could you check for me whether the change I made with 071ef8b solves the issue for you?

antlampas commented 3 years ago

it works! thank you :+1: