Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Link Precompiled Library to Project #2424

Closed
DudeWithAHat opened this issue Jan 24, 2025 · 1 comment
Closed

Cannot Link Precompiled Library to Project #2424

DudeWithAHat opened this issue Jan 24, 2025 · 1 comment
Labels

Comments

@DudeWithAHat
Copy link

I created a precompiled GoogleTest build, since GoogleTest only supports cmake by default, using the following documentation: https://github.com/google/googletest/tree/main/googletest#generic-build-instructions

The compiled directory looks as follows:

GoogleTest
|
--- include
| |
| - **.h # directory of directories of headers
|
--- lib
| |
| --- cmake
| |
| --- pkgconfig
| |
| --- libgmock_main.a
| --- libgmock.a
| --- libgtest_main.a
| --- libgtest.a
|
--- Build-GoogleTest.lua

The current links and includes in my project directory look as follows:

    libdirs { "lib" }
    links { "gmock_main", "gmock", "gtest_main", "gtest" }
    includedirs { "include" }

However, I keep receiving undefined reference errors.

What's your question?

How do I properly tell Premake to use the libraries I have created?

Anything else we should know?
I saw documentation on externalproject, but I was not able to get it to work, nor could I find a working example.

Working on VSCode in Linux.

@DudeWithAHat
Copy link
Author

After ~16 hours of trial and error, I found that:

'links' needs the library files, excluding the 'lib' prefix and the '.a' suffix in my code, as was being done in the code above.

libdirs needs to point to the directory that includes the '.a' files, as shown above as well.

However, the project that uses the libraries needs to link to the libraries as well.

I still believe that clarificiation on how to connect a library in the wikipedia could be useful for others who encounter this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant