Linked Questions
23 questions linked to/from Call a C function from C++ code
0 votes
0 answers
69 views
Is there a way to work with both C and C++? [duplicate]
I am working on a project that I am writing in C++ but I am using some helper functions that were written in C. Since everybody is saying that compiling C source code with g++ is a big nono, is there ...
410 votes
5 answers
328k views
Combining C++ and C - how does #ifdef __cplusplus work?
I'm working on a project that has a lot of legacy C code. We've started writing in C++, with the intent to eventually convert the legacy code, as well. I'm a little confused about how the C and C++ ...
6 votes
1 answer
17k views
error: expected unqualified-id on extern "C"
I have a cpp code in which I want to call a c function. Both compile well to .o files, but when the clang++ is executing for compilation, I receive the following error: file.cpp:74:12: error: ...
2 votes
2 answers
6k views
How to call C DLL functions C++/CLI
I have looked into lot of online searches and most have examples which talk about C# with C or C++ with C# but have never come across using C DLL calling from C++ (specifically from C++/CLI with WPF ...
3 votes
3 answers
5k views
Compile and link C++ and C programms together with QT-Creator
so I have serveal C++ files and basically need to call a C function after the C++ part of my program is done. So if there is a way to just somehow magically "start the C file" (I hope you know what I ...
2 votes
1 answer
2k views
C++ multiple string matching without using regex
I'm trying to edit an existing C++ program to search text for multiple strings rather than a single string. I'm a complete C++ noob so I'm hoping someone can point me to a function that will work and ...
0 votes
2 answers
2k views
ffmpeg undefined references on multiple functions
I am trying to compile an application that is using ffmpeg on Ubuntu and I am running into the following errors. undefined reference to `av_write_image_line2' undefined reference to `...
1 vote
1 answer
2k views
c++ undefined symbols for architecture x86_64: "function_name" referenced from [duplicate]
Yes, I know there's already several questions that go into detail about this, but I feel like my question isn't that detail-specific. Just something staring at me in the face, but I can't quite see it....
0 votes
1 answer
2k views
gcc static linking undefined references
I made a static library using ar to make a simple word counter, but when I reach the linking stage in my makefile, I get the following error: g++ -o wordcount obj/word.o obj/main.o -Wall -L lib -...
2 votes
3 answers
927 views
Makefile with two targets and two languages
I work with C and C++ and thanks to this answer I was able to compile and run my project. Now I am writing a makefile to spare time. But things are getting complicated : Project structure ...
0 votes
1 answer
960 views
Calling C function from C++ with same name
I have read this answer but I do not know what to do if I have the two functions in C++ and C have the same name. The C function is already guarded with if #ifdef __cplusplus in the header file. so I ...
0 votes
0 answers
930 views
cmake Undefined reference to functions
Here's the relevant part of my project structure iNode ├── CMakeLists.txt ├── src | └──iNode.c ├── include | └──iNode.h └── test └──tests.cpp cmake can't find function definitions from iNode....
0 votes
1 answer
318 views
Why linking .cc file works in make file but linking .c file doesn't?
I'm working on a quite large Makefile from the tensorflow repo and I need to add a file link. After quite some debugging of a link error, I found out that if my file ends with .cc, then the link ...
2 votes
2 answers
366 views
Is there anyway to use data.table's fread C implementation in C++?
My ultimate goal is to use a fast csv parser in C++. I have looked at the following libraries: https://github.com/ben-strasser/fast-cpp-csv-parser https://github.com/vincentlaucsb/csv-parser#...
1 vote
2 answers
184 views
Make alias to C types in C++ namespace
I have a DLL in pure C code. I would like to find a way to remove the library name prefix from the functions, classes, and structs; EX: // lib.h void foobar(); // lib.hpp namespace foo { bar(); } ...