leadedge / ofxNDI

An Openframeworks addon to allow sending and receiving images over a network using the NewTek Network Device Protocol.
GNU General Public License v3.0
134 stars 48 forks source link

error when compiling example on raspberry pi 4: undefined reference to ofxNDIutils::CopyImage #50

Closed cyberboy666 closed 4 months ago

cyberboy666 commented 4 months ago

i am running openframeworks: of_v0.12.0_linuxaarch64_release.tar.gz on raspi-os: 2024-03-15-raspios-bookworm-armhf-lite.img on a raspberry pi 4

when i try to compile the example-sender-receiver example i get the following compile errors:

/usr/bin/ld: /home/tim/openframeworks/addons/obj/linuxaarch64/Release/ofxNDI/src/ofxNDIsend.o: in function `ofxNDIsend::SendImage(unsigned char const*, unsigned int, unsigned int, bool, bool)':
ofxNDIsend.cpp:(.text+0x1004): undefined reference to `ofxNDIutils::CopyImage(unsigned char const*, unsigned char*, unsigned int, unsigned int, unsigned int, bool, bool)'
/usr/bin/ld: /home/tim/openframeworks/addons/obj/linuxaarch64/Release/ofxNDI/src/ofxNDIsend.o: in function `ofxNDIsend::SendImage(unsigned char const*, unsigned int, unsigned int, unsigned int, bool)':
ofxNDIsend.cpp:(.text+0x11c0): undefined reference to `ofxNDIutils::FlipBuffer(unsigned char const*, unsigned char*, unsigned int, unsigned int)'
/usr/bin/ld: /home/tim/openframeworks/addons/obj/linuxaarch64/Release/ofxNDI/src/ofxNDIsender.o: in function `ofxNDIsender::ReadTexturePixels(ofTexture, unsigned int, unsigned int, unsigned char*)':
ofxNDIsender.cpp:(.text+0x604): undefined reference to `ofxNDIutils::CopyImage(unsigned char const*, unsigned char*, unsigned int, unsigned int, unsigned int, bool, bool)'
collect2: error: ld returned 1 exit status
make[1]: *** [/home/tim/openframeworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:406: bin/example-sender-receiver] Error 1
make[1]: Leaving directory '/home/tim/openframeworks/addons/ofxNDI/example-sender-receiver'
make: *** [/home/tim/openframeworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:129: Release] Error 2

any ideas what is going wrong here ?

i have had this addon compiling and running on rpi4 before (pretty sure it was of12.0 last time also.. so not sure why this is happening)

leadedge commented 4 months ago

It's likely to be a namespace problem, although it does not appear for Windows.

I have just made some revisions and added the "ofxNDIutils::" prefix to CopyImage and FlipBuffer. Try removing the prefix and let me know what happens.

Edit - Without the prefix, you might need to add "using namespace ofxNDIutils" to ofxNDIsend.h and ofxNDIsender.h.

Correction, just to ofxNDIsend.h and you need a ' ; ' at the end using namespace ofxNDIutils;

leadedge commented 4 months ago

I found a potential definition problem in the recent revision -

ifdef WIN32 instead of #if defined(TARGET_WIN32)

Try your project with the new ofxNDIutils files. Also - keep the the "ofxNDIutils::" prefix.

cyberboy666 commented 4 months ago

thanks a lot @leadedge for the quick reply!

i tried first just pulling your new commit with definition fix, but this didnt change the issue i was having.

then i next i tried removing the ofxNDutils:: prefix from CopyImage and FlipBuffer. also no luck here. however what was a bit interesting is that if i try compile after removing prefix but before adding a using namespace ofxNDIutils; i get this error:

/home/tim/openframeworks/addons/ofxNDI/src/ofxNDIsend.cpp: In member function ‘bool ofxNDIsend::SendImage(const unsigned char*, unsigned int, unsigned int, bool, bool)’:
/home/tim/openframeworks/addons/ofxNDI/src/ofxNDIsend.cpp:367:25: error: ‘CopyImage’ was not declared in this scope; did you mean ‘ofxNDIutils::CopyImage’?
  367 |                         CopyImage((const unsigned char *)pixels, (unsigned char *)video_frame.p_data,
      |                         ^~~~~~~~~
      |                         ofxNDIutils::CopyImage
In file included from /home/tim/openframeworks/addons/ofxNDI/src/ofxNDIsend.h:53,
                 from /home/tim/openframeworks/addons/ofxNDI/src/ofxNDIsend.cpp:103:
/home/tim/openframeworks/addons/ofxNDI/src/ofxNDIutils.h:97:14: note: ‘ofxNDIutils::CopyImage’ declared here
   97 |         void CopyImage(const void* source, void* dest,
      |              ^~~~~~~~~
/home/tim/openframeworks/addons/ofxNDI/src/ofxNDIsend.cpp: In member function ‘bool ofxNDIsend::SendImage(const unsigned char*, unsigned int, unsigned int, unsigned int, bool)’:
/home/tim/openframeworks/addons/ofxNDI/src/ofxNDIsend.cpp:467:25: error: ‘FlipBuffer’ was not declared in this scope; did you mean ‘ofxNDIutils::FlipBuffer’?
  467 |                         FlipBuffer(pixels, p_frame, width, height);
      |                         ^~~~~~~~~~
      |                         ofxNDIutils::FlipBuffer

which is weird that the compiler is suggesting exactly what i changed ??

but then still with prefix removed but using namespace ofxNDIutils; added into ofxNDIsend.h we are back to this error:

/usr/bin/ld: /home/tim/openframeworks/addons/obj/linuxaarch64/Release/ofxNDI/src/ofxNDIsend.o: in function `ofxNDIsend::SendImage(unsigned char const*, unsigned int, unsigned int, bool, bool)':
ofxNDIsend.cpp:(.text+0x1004): undefined reference to `ofxNDIutils::CopyImage(unsigned char const*, unsigned char*, unsigned int, unsigned int, unsigned int, bool, bool)'
/usr/bin/ld: /home/tim/openframeworks/addons/obj/linuxaarch64/Release/ofxNDI/src/ofxNDIsend.o: in function `ofxNDIsend::SendImage(unsigned char const*, unsigned int, unsigned int, unsigned int, bool)':
ofxNDIsend.cpp:(.text+0x11c0): undefined reference to `ofxNDIutils::FlipBuffer(unsigned char const*, unsigned char*, unsigned int, unsigned int)'
/usr/bin/ld: /home/tim/openframeworks/addons/obj/linuxaarch64/Release/ofxNDI/src/ofxNDIsender.o: in function `ofxNDIsender::ReadTexturePixels(ofTexture, unsigned int, unsigned int, unsigned char*)':
ofxNDIsender.cpp:(.text+0x604): undefined reference to `ofxNDIutils::CopyImage(unsigned char const*, unsigned char*, unsigned int, unsigned int, unsigned int, bool, bool)'
collect2: error: ld returned 1 exit status
make[1]: *** [/home/tim/openframeworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:406: bin/example-sender-receiver] Error 1
make[1]: Leaving directory '/home/tim/openframeworks/addons/ofxNDI/example-sender-receiver'
make: *** [/home/tim/openframeworks/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:129: Release] Error 2

seems very strange to me. unfortunately theres not much more i can figure out here with my limited knowledge of cpp but happy to try any other suggestions you have

leadedge commented 4 months ago

I have uploaded the current master to the "testing" branch and will make some modifications to that.

cyberboy666 commented 4 months ago

im not sure if its helpful to note here - but when i checkout the testing branch and try compile example-sender-receiver i get:

In file included from /home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.cpp:36:
/home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.h:36:10: fatal error: windows.h: No such file or directory
   36 | #include <windows.h>
      |          ^~~~~~~~~~~
compilation terminated.

then if i comment out the #include <windows.h> here (im guessing i dont need it on linux?)

i get next many many lines of errors:

/home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.h:62:20: error: variable ‘SPOUT_DLLEXP ofxNDIshaders’ has initializer but incomplete type
   62 | class SPOUT_DLLEXP ofxNDIshaders {
      |                    ^~~~~~~~~~~~~
/home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.h:64:9: error: expected primary-expression before ‘public’
   64 |         public:
      |         ^~~~~~
/home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.h:64:9: error: expected ‘}’ before ‘public’
/home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.h:62:34: note: to match this ‘{’
   62 | class SPOUT_DLLEXP ofxNDIshaders {
      |                                  ^
/home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.h:64:9: error: expected ‘,’ or ‘;’ before ‘public’
   64 |         public:
      |         ^~~~~~
/home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.h:67:31: error: expected class-name before ‘(’ token
   67 |                 ~ofxNDIshaders();
      |                               ^
/home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.h:70:27: error: ‘GLuint’ was not declared in this scope; did you mean ‘uint’?
   70 |                 bool Copy(GLuint SourceID, GLuint DestID,
      |                           ^~~~~~
      |                           uint
/home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.h:70:44: error: ‘GLuint’ was not declared in this scope; did you mean ‘uint’?
   70 |                 bool Copy(GLuint SourceID, GLuint DestID,
      |                                            ^~~~~~
      |                                            uint
/home/tim/openframeworks/addons/ofxNDI/src/Backup_09-05-24_hdr-and-UVYV-testing/ofxNDIshaders.h:71:25: error: expected primary-expression before ‘unsigned’
   71 |                         unsigned int width, unsigned int height,
      |                         ^~~~~~~~

looks like it doesnt recognize the def class SPOUT_DLLEXP ofxNDIshaders {

let me know if there is anything else i can test and thanks a lot for your help!

leadedge commented 4 months ago

This was restored from a USB drive and I forgot to remove all the source backup folders. They are gone now and it should build.

I also created a "Backup" branch for the version previous to the latest revisions. There have been no reports of namespace issues for this and it should build without error. If not, it gives a direction to investigate further.

What is your compiler? I assume you get ofxNDIutils.o and it is linked with the others.

leadedge commented 4 months ago

I found a missing #endif in ofxNDIutils.cpp. Master is updated. It's possible that it will build now.

cyberboy666 commented 4 months ago

latest version compiles fine now on my machine - thank you so much for your work!