That worked, thanks! I changed the makefile and added the missing .h
files too (sorry for that...). I also took care of all the warning
massages, now the object compiles without any warnings.
Thanks for the help
P.S. How to mark examples/map.pd as a non-executable?
On 8/7/24 11:35, IOhannes m zmoelnig wrote:
On 8/7/24 07:50, Alexandros Drymonitis wrote:
>
> On 8/7/24 08:46, Alexandros Drymonitis wrote:
>> You're both right, sorry for not providing one from the start. Here
>> it is: https://github.com/alexdrymonitis/neuralnet/tree/develop
>>
thanks.
>
Actually, now I get a compile error, saying that there are multiple
definitions of these three functions, but I really can't see where
these are, since these are only defined in the dense.h and dense.c
files.
the root of your problem is, that the Makefile tries to link the
'dense.o' objectfile **twice** into the final neuralnet.pd_linux
```
++++ info: linking objects in neuralnet.pd_linux for lib neuralnet
cc -rdynamic -shared -fPIC -Wl,-rpath,"\$ORIGIN",--enable-new-dtags -o
neuralnet.pd_linux neuralnet.pd_linux.o dense.pd_linux.o
dense.pd_linux.o -lc -lm
```
since the dense.o objectfile holds a single definition of
"dropout_forward" (and friends), linking it twice results in a
duplicate definition, thus leading to the error
(the linker does not try to detect duplicate object files).
the cause for this problem is, that you added the header-file
'dense.h' to the "common.sources".
while a header file is arguably a "source" file, pd-lib-builder
assumes that sources are files **to be compiled**.
this is a common dichotomy: <https://stackoverflow.com/questions/3482948>
so removing the dense.h file from your "sources" fixes the problem.
apart from that:
conceptually 'common.sources' is for source-files that are common to
all objects within a library.
if you want to just split the sources for a single object, you can
instead use "<object>.class.sources", e.g.:
```diff
iff --git a/Makefile b/Makefile
index 88a8168..8edf8c5 100755
--- a/Makefile
+++ b/Makefile
@@ -2,9 +2,7 @@
lib.name = neuralnet
-class.sources = neuralnet.c
-
-common.sources = dense.h dense.c
+neuralnet.class.sources = neuralnet.c dense.c
datafiles = neuralnet-help.pd README.md
```
now your "library" is a single-object lib, where there's little
difference.
but if you think of any additional (helper) object that might become
part of your library (turning it into a multi-object lib), and such an
additional object won't need dense.c, you probably should go with
*.class.sources
you *really* should pay attention to the compiler warnings.
there are a couple of implicit pointer casts from (t_atom*) to
(t_float*). a modern compiler (e.g. gcc-14), will simply refuse to
build such code.
unfortunately, there are a couple of warnings that are hard (or
impossible) to get rid-of, to the signal to noise ratio is quite high.
it typically helps a lot when suppressing warnings about unused
thingies (by adding "suppress-wunused=1" to your make invocation)
there's also the "cast-function-type" warning, which you cannot
practically fix for registering callbacks (e.g. in "class_new" or
"class_addmethod")
some includes (rnn.h, embedded.h) are missing from the repository (or
the README should mention which dependencies you need to install).
(i'm rather old-school and prefer to build code that I need to review)
your Makefile marked is executable, but doesn't define a shebang.
examples/map.pd is also (wrongly) marked as executable.
gmasdr
IOhannes
_______________________________________________
Pd-dev mailing list
[email protected]
https://lists.puredata.info/listinfo/pd-dev
_______________________________________________
Pd-dev mailing list
[email protected]
https://lists.puredata.info/listinfo/pd-dev