Hi devs, I'm trying to get pd-lib-builder working, but I think my lack of C building experience has me stuck. I was able to get my empty helloworld working ok, but not managing to link in S7.
My project has one C file, and needs to also include s7.h and build s7.c I've included my (not working) Makefile below. When I try the below s7 does get compiled, producing an s7.o file, but instead of static linking I get an s7.pd_darwin file with all of the S7 stuff (it's big) and a tiny s4pd.pd_darwin file. And the external tries to load an s7 function and fails. Any tips much appreciated!
thanks, Iain
My Makefile:
# library name lib.name = s4pd
# tried these too, to no avail #lib.setup.sources = s7.c #common.source = s7.c
# input source file (class name == source file basename) class.sources = s4pd.c s7.c
# all extra files to be included in binary distribution of the library datafiles = README.md
# include Makefile.pdlibbuilder from submodule directory 'pd-lib-builder' PDLIBBUILDER_DIR=pd-lib-builder/ include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder
Hi,
here's the explanation: https://github.com/pure-data/pd-lib-builder/blob/e6cff665a3a30a967c72c382c6f...
"class.sources" assumes one source per class. What you need is "<classname>.class.sources", i.e. "s4pd.class.sources = s4pd.c s7.c"
"common.sources" would have worked too, you just made a typo ;-) However, I think the solution above is clearer, as "common.sources" is really meant for the case where you have *multiple* classes with same shared code.
Christof
On 27.10.2020 23:44, Iain Duncan wrote:
Hi devs, I'm trying to get pd-lib-builder working, but I think my lack of C building experience has me stuck. I was able to get my empty helloworld working ok, but not managing to link in S7.
My project has one C file, and needs to also include s7.h and build s7.c I've included my (not working) Makefile below. When I try the below s7 does get compiled, producing an s7.o file, but instead of static linking I get an s7.pd_darwin file with all of the S7 stuff (it's big) and a tiny s4pd.pd_darwin file. And the external tries to load an s7 function and fails. Any tips much appreciated!
thanks, Iain
My Makefile:
# library name lib.name http://lib.name = s4pd
# tried these too, to no avail #lib.setup.sources = s7.c #common.source = s7.c
# input source file (class name == source file basename) class.sources = s4pd.c s7.c
# all extra files to be included in binary distribution of the library datafiles = README.md
# include Makefile.pdlibbuilder from submodule directory 'pd-lib-builder' PDLIBBUILDER_DIR=pd-lib-builder/ include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder
Pd-dev mailing list Pd-dev@lists.iem.at https://lists.puredata.info/listinfo/pd-dev
Ah thanks, that did it! I also figured out I could build by adding
cflags = -I . -L . -l s7
but that did seem to be defeating the whole purpose the of the magic make file.
Compiling now, thanks! iain
On Tue, Oct 27, 2020 at 4:03 PM Christof Ressi info@christofressi.com wrote:
Hi,
here's the explanation: https://github.com/pure-data/pd-lib-builder/blob/e6cff665a3a30a967c72c382c6f...
"class.sources" assumes one source per class. What you need is "<classname>.class.sources", i.e. "s4pd.class.sources = s4pd.c s7.c"
"common.sources" would have worked too, you just made a typo ;-) However, I think the solution above is clearer, as "common.sources" is really meant for the case where you have *multiple* classes with same shared code.
Christof On 27.10.2020 23:44, Iain Duncan wrote:
Hi devs, I'm trying to get pd-lib-builder working, but I think my lack of C building experience has me stuck. I was able to get my empty helloworld working ok, but not managing to link in S7.
My project has one C file, and needs to also include s7.h and build s7.c I've included my (not working) Makefile below. When I try the below s7 does get compiled, producing an s7.o file, but instead of static linking I get an s7.pd_darwin file with all of the S7 stuff (it's big) and a tiny s4pd.pd_darwin file. And the external tries to load an s7 function and fails. Any tips much appreciated!
thanks, Iain
My Makefile:
# library name lib.name = s4pd
# tried these too, to no avail #lib.setup.sources = s7.c #common.source = s7.c
# input source file (class name == source file basename) class.sources = s4pd.c s7.c
# all extra files to be included in binary distribution of the library datafiles = README.md
# include Makefile.pdlibbuilder from submodule directory 'pd-lib-builder' PDLIBBUILDER_DIR=pd-lib-builder/ include $(PDLIBBUILDER_DIR)/Makefile.pdlibbuilder
Pd-dev mailing listPd-dev@lists.iem.athttps://lists.puredata.info/listinfo/pd-dev
Pd-dev mailing list Pd-dev@lists.iem.at https://lists.puredata.info/listinfo/pd-dev
On 10/28/20 12:09 AM, Iain Duncan wrote:
cflags = -I . -L . -l s7
if this works, then it's only because you somehow managed to have a libs7.so (or libs7.a) file lying around, against which it linked.
afaict, this is not a safe assumption
gdfmasdr IOhannes
and some more nitpicking:
i think it's better style to omit the spaces after the -I/-L/-l flags: cflags = -I. -L. -ls7
also the "-I." is only useful if you happen to use includes with angled-brackets (e.g. '#include <s7.h>') as opposed to includes with quotes (e.g. '#include "s7.h"'). if you want to include the local header file anyhow (rather than some system-installed header of the same name) you should use includes-with-quotes rather than add '-I' to the cflags.
and "-L" and "-l" are really linker flags. you should *not* add them to cflags. instead of "ldlibs" resp. "ldflags".
Hey thanks for that, I was aware I was cargo-culting there haha, so the explanation is much appreciated. :-)
iain
On Wed, Oct 28, 2020 at 9:29 AM IOhannes m zmoelnig zmoelnig@iem.at wrote:
On 10/28/20 12:09 AM, Iain Duncan wrote:
cflags = -I . -L . -l s7
if this works, then it's only because you somehow managed to have a libs7.so (or libs7.a) file lying around, against which it linked.
afaict, this is not a safe assumption
gdfmasdr IOhannes
and some more nitpicking:
i think it's better style to omit the spaces after the -I/-L/-l flags: cflags = -I. -L. -ls7
also the "-I." is only useful if you happen to use includes with angled-brackets (e.g. '#include <s7.h>') as opposed to includes with quotes (e.g. '#include "s7.h"'). if you want to include the local header file anyhow (rather than some system-installed header of the same name) you should use includes-with-quotes rather than add '-I' to the cflags.
and "-L" and "-l" are really linker flags. you should *not* add them to cflags. instead of "ldlibs" resp. "ldflags".
Pd-dev mailing list Pd-dev@lists.iem.at https://lists.puredata.info/listinfo/pd-dev