Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ofxNetwork on an iOS project hijacks OF's main() #5980

Closed
armadillu opened this issue Apr 20, 2018 · 5 comments
Closed

Using ofxNetwork on an iOS project hijacks OF's main() #5980

armadillu opened this issue Apr 20, 2018 · 5 comments

Comments

@armadillu
Copy link
Contributor

Making a new ios project with PG, if ofxNetwork is added, your project will not launch when run. Instead, the app spits out this huge table and quits.

//
// This is an automatically generated file.
// Do not edit.
//

const unsigned short expTable[] =
{
    0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 
    0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 
    0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 
    0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 
    0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 0x3c00, 
    ...

Googling lead me to this... Apparently there's an int main()function within the freeimage library??? WTF??

Anyway, somehow, including ofxNetwork makes the project launch that main() within FreeImage instead of the main() defined in your project's main.mm file. I've painstakingly isolated the issue within ofxNetwork; it turns out the ofxUDPManager.cpp file is to blame. If you remove ofxUDPManager.cpp from the project and run it, the expected main() is launched, and the app works as normal. If you add it back, the freeImage main() runs instead.

At this point I was too curious to stop, so I've been slowly commenting out code within ofxUDPManager.cpp and re-running the project to see what part of the code could possible be responsible for this bizzare feat...

I've isolated it to the method ofxUDPManager::BindMCast(char *pMcast, unsigned short usPort), and even more precisely, this line:

ofLogWarning("ofxUDPManager") << "BindMcast(): couldn't bind to port " << usPort;

Leaving this line as it is, makes the project not launch. Commenting it out, makes the project work as normal.

This is one of the weirdest things I've ever seen, I would love to hear a rational explanation of what's triggering this! I wonder if it's a linker bug of some sort?

I can be reproduce this using the latest Master and also a much older revision (~mid-2017). I'm using macOS 10.13.3 to test, and the latest XCode (9.3).

@armadillu armadillu changed the title using ofxNetwork on an iOS project hijacks OF's main() Using ofxNetwork on an iOS project hijacks OF's main() Apr 20, 2018
@arturoc
Copy link
Member

arturoc commented Apr 20, 2018

wtf. perhaps we can try to remove that file before compiling freeimage for ios

@arturoc
Copy link
Member

arturoc commented Apr 20, 2018

btw, I think freeimage uses some flag to hide internal symbols from binaries linking to it but no idea why that one specific line would unhide it.

@armadillu
Copy link
Contributor Author

Also worth nothing, the same thing happens in both the Simulator and a real iOS device, so It affects both architectures the same way...

@arturoc
Copy link
Member

arturoc commented Apr 22, 2018

This should be solved now but would be good if you can check.

@arturoc arturoc closed this as completed Apr 22, 2018
@armadillu
Copy link
Contributor Author

armadillu commented Apr 23, 2018

Yep I just tested on RC2 and the freeImage main() doesn't seem to show up no matter what I try.
It certainly doesn't show up under the circumstances that triggered it before either.
I think it's fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants