0

I have the next problem, when i intent to generate the executable of my application, the system show me the next message :

undefined reference to `sum'
undefined reference to `rest'
undefined reference to `multi'

With the case of div, the application show me a false result.

I can create the package, also I can compile using Cmake, and the system don't show me errors but when i intent to generate my executable the system show me those messages, and I don't know why, so I show you my consumer files like CMakeLists and conanfile. I excpect that you can help me !!

CMakeLists. txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(Example C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

SET(MyExample_SRC 
"main.c")

add_executable(example ${MyExample_SRC})
target_link_libraries(example ${CONAN_LIBS})

conanfile.txt

[requires]
Exa/0.1@edwin/testing

[generators]
cmake

This the conanfile.py that I used to create my package:

from conans import ConanFile, CMake, tools


class ExaConan(ConanFile):
   name = "Exa"
   version = "0.1"
   settings = "os", "compiler", "build_type", "arch"
   generators = "cmake"

    def source(self):
        #self.run("CD C:/projects/connan-example/pkg")
        pass

    def build(self):
        self.run("CD C:/projects/connan-example/pkg/ & Compile.bat")
        #cmake = CMake(self)
        #make.configure(source_folder="connan-example")
        #cmake.build()

    def package(self):
        self.copy("MultiDiv.obj", dst="objects", keep_path=False)
        self.copy("SumRest.c", dst="source", keep_path=False)
        #self.copy("*.lib", dst="lib", keep_path=False)


    def package_info(self):
        #self.c_info.libs = ["example"]
        pass

The Compile.bat is just to create the file .obj for MultDiv, and like the file shows, I'm packing MultiDiv and SumRest. When i compile and generate the executable with gcc commands, I can do it successfully

Pony94
  • 1
  • 1

1 Answers1

0

You are missing some information:

  • The ${CONAN_LIBS} variable that you see in the CMakeLists.txt gets its value from the dependencies package_info() method. As your package_info() method is empty, it is not passing the information to consumers, and they don't need how to link with them.
  • You are not using a proper lib. You need to create an actual static ".lib", ".a" library or a shared library, and package it to the "lib" directory. Or if not packaging it (in the package() method) to that directory, define self.cpp_info.libdirs=["yourlibdir"] accordingly
  • Even if it might be possible to use OBJECT "libraries" in CMake, they cannot be fully used as targets (I think it has been added in very last CMake 3.12) in CMake
drodri
  • 5,157
  • 15
  • 21