question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] pkg_config generator with layout generates invalid .pc file

See original GitHub issue

I’m quite new to conan and trying to integrate it into our current build flow (not from scratch).

We use cmake which finds its dependencies with pkg_config (pkg_search_module). So I set up a test of two libs one requiring another, LibA depends on LibB. So when building LibA the pkg_config generator succesfully generates the .pc files

prefix=/home/.conan/data/libB/1.0.0_conan/company/testing/package/abd3ca9581f5ec3d6672fa2ee8818b1f09dbb082
libdir=${prefix}/lib
includedir=${prefix}/include

Name: libB-lib
Description: Generic purpose library for CPP development
Version: 1.0.0_conan
Libs: -L"${libdir}" -lcomet  -lcomet-tests  -Wl,-rpath,"${libdir}"
Cflags: -I"${includedir}"

So far so good, now I wanted to switch to layouts and to use the editable feature.

I changed the conanfile of libB from

  def build(self):
        cmake = CMake(self)
        cmake.verbose = True
        cmake.definitions["COMPILE_INTEGRATION_TESTS"] = "OFF"
        cmake.definitions["GENERATE_CODE_COVERAGE"] = "OFF"
        cmake.definitions["RUN_TESTS"] = "OFF"
        cmake.definitions["CMAKE_INSTALL_PREFIX"] = "deploy"
        cmake.configure(build_folder="build", source_folder=".")
        cmake.build()
        cmake.install()

    def package(self):
        self.copy("*", src="build/deploy")

    def package_info(self):
        self.cpp_info.libs = tools.collect_libs(self)

to

def layout(self):
        # ###### FOLDERS
        self.folders.build = "build"

        # We want to have the toolchains in the build folder so we can always pass
        # `-DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake` to CMake
        self.folders.generators = os.path.join(self.folders.build, "generators")

        # In case we use "conan package" we declare an output directory
        self.folders.package = "deploy"

        # ###### INFOS
        self.cpp.source.includedirs = ["src"] # Relative to ["."] (self.folders.source)
        self.cpp.build.libdirs = ["deploy/lib"]  # Relative to (self.folders.build)

    def build(self):
        cmake = CMake(self)
        cmake.verbose = True
        cmake.definitions["COMPILE_INTEGRATION_TESTS"] = "OFF"
        cmake.definitions["GENERATE_CODE_COVERAGE"] = "OFF"
        cmake.definitions["RUN_TESTS"] = "OFF"
        cmake.definitions["CMAKE_INSTALL_PREFIX"] = "deploy"
        cmake.configure()
        cmake.build()
        cmake.install()

    def package(self):
        LayoutPackager(self).package()

    #def package_info(self):
    #    self.cpp_info.libs = tools.collect_libs(self)

Now the pkg generator of LibA creates the following .pc file

prefix=/home/.conan/data/libB/1.0.0_conan/company/testing/package/abd3ca9581f5ec3d6672fa2ee8818b1f09dbb082

Name: libB-lib
Description: Conan package: libB
Version: None
Libs: 
Cflags: 

What am I doing wrong? What makes it hard for me to track down the problem is, that I don’t know where actually the information comes from to generate the .pc file. I can not find anything in the .conan folder.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
joastoecommented, Nov 3, 2021

Of course you’re right @memsharded, although the issue is quite related. I opened a new issue here: Indirect dependencies missing when using PkgConfigDeps This issue can be closed, indeed. Thanks!

0reactions
memshardedcommented, Nov 3, 2021

@joastoe If the issue above was solved, then maybe we can close this issue, and open your last comment as a new one? Seems not the same issue.

Please also complete, just in case, are libA->libB->libC regular requires? No build_requires or any other different type of requirement?

Read more comments on GitHub >

github_iconTop Results From Across the Web

install: add EXPORT mode to generate pkg-config files ...
We may be able to generate pkg-config files for CMake packages by extending install(EXPORT) with a mode to generate .pc files.
Read more >
pkg-config and .pc files — conan 1.44.1 documentation
Approach 5: Use the pkg_config generator¶. If you use package_info() in library B and library C, and specify all the library names and...
Read more >
3 Common Tasks
create -layers-setup : Writes out a configuration file and/or a script that can replicate the directory structure and revisions of the layers in...
Read more >
log4net generates wrong log file name after rolling log files
Now I have a problem. Everytime log4net rolls log file, it doesn't change the date part of log file. For example if today's...
Read more >
B2 User Manual - 1.81.0
The project is described by a file called Jamfile that contains: exe hello : hello.cpp ; ... Produces debug output from the generator...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found