C++ code successfully compiled found and recognized by Pd--can anyone tell me how to get it to load? Thx
-
cannot dynamically load position-independant executable
-
@jim Not my subject so I am probably spouting rubbish...... but Pd looks for objects by name in its search paths and loads them as you create objects in a patch.
However, a position independent executable with random address allocation (if I understand correctly) probably needs to be incorporated into Pd as it runs.
So if your executable is named myexe.exe (for example) maybe starting Pd with a command line flag....... -lib myexe .... could work and avoid memory allocation conflicts.
David. -
@Jim, can you share your code? How are you setting up your object in your code? Is it a multi-object/one-executable library you're trying to load, a many-executables library, or a single object?
-
It's a single .cpp file. I'm learning that the position-independent executable flag is created at compile time. I think I need to know how to compile to a non PIE. Nothing in the source code goes to memory allocation...there's no new or static or anything. I tried using the makefile in pd docs but it apparently ignores my file. Hold on I'll give you the source
-
#include "m_pd.h"
#include <iostream>
class helloworld {
public:
helloworld() {}
void bang() {
std::cout << "Hello world !!" << std::endl;
}
};int main() {
helloworld obj;
obj.bang();
return 0;
} -
@whale-av I tried to open Pd this way but got the same error, plus cannot open library, but thanks!
-
idk that much about c++, but I'm pretty sure there shouldn't be a 'main' function. In pd you compile objects as libraries. You have to look at the 'how to program externals' book. https://github.com/pure-data/externals-howto#definitions-and-prerequisites
Plus I'm pretty sure you have to export stuff correctly (as 'c') so that the object loader knows how to load it
you might try the 'flext' framework or look at the ceammc distribution (I think they might use c++?
https://github.com/grrrr/flext
https://github.com/uliss/pure-data/blob/ceammc/ceammc/ext/class-wrapper/README.md
https://github.com/uliss/pure-data/blob/ceammc/ceammc/ext/src/lib
Also it would be helpful to post the command you're using to compile it -
@seb-harmonik.ar Thx I use ctrl-shift-b for vs code. this launches the build, which for me is with gcc.
-
command line: g++ filename.cpp -o filename.pd_linux -no-pie
works.