Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: error adding symbols: Archive has no index  (Read 3769 times)

0 Members and 1 Guest are viewing this topic.

Popinaodude

  • Newbie
  • *
  • Posts: 3
    • View Profile
error adding symbols: Archive has no index
« on: January 08, 2021, 09:12:55 pm »
I'm getting this strange error when trying to build my project:
C:/Program Files (x86)/SFML/lib/libsfml-graphics-s.a: error adding symbols: Archive has no index; run ranlib to add one
 

I built SFML myself on windows using this guide: https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php and installed SFML into the the windows program files. I'm completely certain that I'm using the same compiler to build SFML and my project. I tried running ranlib over libsfml-graphics-s.a but it didn't seem to do anything.

Here's what my CMakeLists.txt looks like:
cmake_minimum_required(VERSION 3.17)
project(SFML_test)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
set(CMAKE_VERBOSE_MAKEFILE ON)

file(GLOB SOURCES ./*.cpp)
add_executable(SFML_test ${SOURCES})

# SFML
set(SFML_STATIC_LIBRARIES TRUE)
set(SFML_DIR "C:/Program Files (x86)/SFML/lib/cmake/SFML")
find_package(SFML COMPONENTS graphics window system REQUIRED)
target_link_libraries(SFML_test sfml-graphics sfml-window sfml-system)


Popinaodude

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: error adding symbols: Archive has no index
« Reply #1 on: January 08, 2021, 09:29:34 pm »
As it turns out, I WASN'T building SFML and running the project with the same compiler. I have two versions of mingw-64 installed on my computer and even though I had specified which to use, CMake still used the other one. I only discovered this after deleting the other version and trying to run again, it told me the compiler was missing. Once I rebuilt everything with the right compiler everything worked.