How can you link a c program with a c function?



How can you link a c program with a c function?..

Answer / Sujeet Kumar Singh

To link a C program with a C function, first write the C function in a separate '.c' file and put it in a shared library (.so/.dll on Linux/Windows respectively) using a compiler like gcc or clang. Then include the header file containing the function prototype in your C++ code and use the linker to link the shared library when compiling the final C++ program.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

which of the following is not an secondary constant a) array b) real c) union

1 Answers  


Explain what is class definition in c++ ?

1 Answers  


What is encapsulation in c++ with example?

1 Answers  


Describe Trees using C++ with an example.

1 Answers  


What is ofstream c++?

1 Answers  


What are the vectors in c++?

1 Answers  


What is object file? How can you access object file?

1 Answers  


Is c++ a good first language to learn?

1 Answers  


How do you define/declare constants in c++?

1 Answers  


When copy constructor can be used?

4 Answers   Symphony,


What is #include ctype h in c++?

1 Answers  


How does java differ from c and c++?

1 Answers  


Categories