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.

can cmake-js compile projects containing both c code and c++ code appropriately?

See original GitHub issue
  • I’m relatively new with C/C++.

I’m trying to make myself a native c++ addon which depends on the pigpio C Library intended for a Raspberry Pi.

The compilation fails, emitting lots of errors about the main pigpio.c file (written in C code) regarding things like implicit type casting, using the new keyword as a variable name, and more…

Of course, theses errors show only when using cmake-js compile on my whole addon project (which is based on c++ as mentioned); as opposed, trying to compile the pigpio library alone with gcc directly and no c++ code involved - succeeds flawlessly.

Is there a way to tell cmake-js/cmake to treat *.c files as C code and compile them appropriately? Or maybe I’m missing some point…?

Issue Analytics

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

github_iconTop GitHub Comments

shtaifcommented, Aug 22, 2017

Well, as you suggested, the lib author does provide a build script in the pigpio website. I was able to create a file thanks to that, which I added to my project and to my cmake config: target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} pigpio)

I guess the best way should have been to set pigpio in my project with a nested CMakeLists.txt, but for now I’m happy because it works 😃


RSATomcommented, Aug 22, 2017

Glad to hear it. Then please close issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CMake: How to Build and Package C/C++ Projects - YouTube
In this workshop we will learn about CMake, a build generation tool used to build cross platform C /C++ projects. If you are...
Read more >
How to properly link libraries with cmake? - Stack Overflow
My recommendation is to start simple, and then complicate your project further. Let me try to explain how linking works in CMake.
Read more >
CMake Tutorial — CMake 3.19.8 Documentation
The CMake tutorial provides a step-by-step guide that covers common build system issues that CMake helps address. Seeing how various topics all work...
Read more >
Getting Started With CMake - Earthly Blog
When it comes to packaging an application, there are many ways to do it. However, with languages that have been around as long...
Read more >
@ajm/cmake-js NPM |
js module doesn't build your project, CMake does. All of its commands (configure, build, clean, etc.) are simple CMake invocations without involving JS...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found