Yes, of course, without any tools mentioned in the other answers, but simply using the C++ compiler.
just follow these steps from within your C++ program (on linux, but must be similar on other OS)
- write a C++ program into a file (e.g. in /tmp/prog.cc), using an
- compile the program via
system("c++ /tmp/prog.cc -o /tmp/prog.so -shared -fPIC");
- load the program dynamically, e.g. using
- Function with same name but different signature in derived class
- Function does not change passed pointer C++
- Return array in a function
- Static array vs. dynamic array in C++
- When does a constexpr function get evaluated at compile time?
- C++ callback using class member
- Overload a C++ function according to the return value
- Is the return type part of the function signature?
- Meaning of = delete after function declaration
- Should I use std::function or a function pointer in C++?
- Where should I prefer pass-by-reference or pass-by-value?
- Should I use an exception specifier in C++?
- C++ overload resolution [duplicate]
- Is there a reason to call delete in C++ when a program is exiting anyway?
- Why can’t we pass arrays to function by value?
- ‘foo’ was not declared in this scope c++
- Which is more efficient: Return a value vs. Pass by reference?
- Returning a pointer of a local variable C++
- Is there a way to pass auto as an argument in C++?
- C++: Argument Passing “passed by reference”
- Why doesn’t C++ support functions returning arrays?
- Why is std::function not equality comparable?
- C++ inline member function in .cpp file
- Why should default parameters be added last in C++ functions?
- std::bind a bound function
- Difference between a virtual function and a pure virtual function [duplicate]
- Can I set a default argument from a previous argument?
- Why use a const member function?
- Should I pass an std::function by const-reference?
- Simplest way to determine return type of function
- How do I return a char array from a function?
- Function with same name but different signature in derived class not found
- Is it possible to std::move objects out of functions? (C++11)
- Do class functions/variables have to be declared before being used?
- How Non-Member Functions Improve Encapsulation
- Why do we need to use `int main` and not `void main` in C++? [duplicate]
- Function in C++ returns by value or by reference?
- Explanation of function pointers
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)? [closed]
- Initializer list for dynamic arrays?
- C++ Function Callbacks: Cannot convert from a member function to a function signature
- Function returning a lambda expression
- Is there any way a C/C++ program can crash before main()?
- Function pointer as parameter
- Using boost thread and a non-static class function
- c++ –
- How to create a template function within a class? (C++)
- switch “transfer of control bypasses initialization of:” when calling a function
- How much overhead is there in calling a function in C++?
- Differences of using “const cv::Mat &”, “cv::Mat &”, “cv::Mat” or “const cv::Mat” as function parameters?