COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 06-24-2016, 04:54 AM   #1
styro
Human being with feelings
 
Join Date: Feb 2014
Posts: 22
Default Cairo on OSX? porting plugin to mac....

Hello!

i am trying to port the vsti that i made with VS2013 / Cairo / Gamma on win7
(and works quite nicely, many thanks to all of the forum for help&hints)
to osx. after setting up cairo thru macports and correcting some errors and setting the include-path /opt/local/include and linker to link to /opt/local/lib/libcairo.dylib it compiles, it links ... and it crashes instantly at scan :-(

so to test the cairo-install i builded the MyFirstCairoPlugin-example,
and it appears in reaper, but it shows only the knob (and some lice-text to test) but not the cairo-stuff (red-sine-line). (same thing when its build as AU)
i tryed linking with /opt/local/lib/libcairo.dylib,/opt/local/lib/libcairo.a and the stuff in /opt/local/lib/cairo.

when i test the generated MyFirstCairoPlugin.vst on a MacBook (Reaper64 on Maverics 64Bit) it crashes while scanning (and dont show up afterward),
other example-plugins run.

i am building as 64Bit vst2 with xcode 7.2.1 (with sdk 10.5 10.7 10.8 installed, building for 10.7) on a el capitain 64Bit install on VirtualBox (works quite nicely....).

so i would be very grateful for some wdl-ol wisdom....
did someone got cairo working on osx and how?
is the cairo-stuff linked statically to the plugin?
is there anything to take special care for porting to mac?
is there a way to debug the crashing while scanning the plugin,
like something like savihost on windows?

i am new to the xcode, is there some important hints?
many thanks for any help!

all the best
styro
styro is offline   Reply With Quote
Old 06-24-2016, 05:18 AM   #2
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 367
Default

Don't use dynamic linking, use libcairo.a. Also, try reinstalling mac ports and build cairo using "sudo port install cairo +universal" to have universal library that will work on 10.5 SDK and higher...
Youlean is offline   Reply With Quote
Old 06-24-2016, 02:10 PM   #3
styro
Human being with feelings
 
Join Date: Feb 2014
Posts: 22
Default

Thanks for the Answer, unfortunately this didnt help, also
reinstalling Macports and sudo port install cairo +universal
didnt do it.
To look if this was some esoteric behavior of the VirtualBox-ElCapitan
i installed xcode 5.1.1 on my 10.9.5 X64 macbook, macports and did the
"sudo port install cairo +universal",
MyFirstCairoPlugin compiles/links and runs in Reaper, but with the
same problem, it shows no Cairo-stuff, only the knob!!!
would be very grateful for some ideas?

all the best
styro
styro is offline   Reply With Quote
Old 06-24-2016, 04:00 PM   #4
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 367
Default

Try rendering some svg or png in class that uses cairo to verify that cairo is not working.

Check this example: https://en.wikipedia.org/wiki/Cairo_(graphics)

It might be possible that there is a problem in LICE to Cario connection...
Youlean is offline   Reply With Quote
Old 07-12-2016, 01:39 AM   #5
styro
Human being with feelings
 
Join Date: Feb 2014
Posts: 22
Default

Thanks for your Input!

i can dump the surface with
cairo_surface_write_to_png(surface, "/Users/styro/xtxtxtxtxt.png");
and the png looks good,

unsigned int *data = (unsigned int*)cairo_image_surface_get_data(surface);
the returned value is not NULL, so that seems valid too.

loading a test.png and showing it also works :
IBitmap testbitmap = pGraphics->LoadIBitmap(102, "resources/img/test.png", 1);
bool q = pGraphics->DrawBitmap(&testbitmap, &this->mRECT);

So Cairo and LICE are working, so it must be a connection problem.
interestingly when i do this just to check if i can see something:
(knowing that the format is surely not the same)

unsigned int *xX = (unsigned int*)testbitmap.mData;
LICE_WrapperBitmap WrapperBitmap = LICE_WrapperBitmap(xX, this->mRECT.W(), this->mRECT.H(), this->mRECT.W(), false);
IBitmap result(&WrapperBitmap, WrapperBitmap.getWidth(), WrapperBitmap.getHeight());
bool q = pGraphics->DrawBitmap(&result, &this->mRECT);

i get some unsorted pixels, so i could think that part probably also works,
so then the address to the
*data = (unsigned int*)cairo_image_surface_get_data(surface);
could be bogus .... (it points to 0x690C830, is this possible?)

Many thanks for some hints!
greetings styro
styro is offline   Reply With Quote
Old 07-12-2016, 05:42 AM   #6
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 367
Default

Use this code to draw to LICE
Code:
inline void Cairo_Draw_To_Lice(IGraphics *pGraphics, cairo_surface_t *surf, int x, int y, int width, int height)
{
    cairo_surface_flush(surf);
    unsigned int *data = (unsigned int*)cairo_image_surface_get_data(surf);
    IRECT rect = IRECT(x,y,width,height);

#ifdef _WIN32
    
    LICE_WrapperBitmap WrapperBitmap = LICE_WrapperBitmap(data, width, height, width, false);
    IBitmap result(&WrapperBitmap, width, height);
    pGraphics->DrawBitmap(&result, &rect);
    
#elif defined(__APPLE__)
    
        for(int i = 0; i < (width * height); ++i)
    {
        // argb to bgra   aaaaaaaa rrrrrrrr gggggggg bbbbbbbb    to    bbbbbbbb gggggggg rrrrrrrr aaaaaaaa
        
        *data = (*data >> 24) | (*data << 24) | ((*data &0xFF0000) >> 8) | ((*data &0xFF00) << 8);
        //       ___a           b__a             b_ra                           bgra
        
        
        data = data + 1;
    }
    data = data - (width * height);
    LICE_WrapperBitmap WrapperBitmap = LICE_WrapperBitmap(data, width, height, width, false);
    IBitmap result(&WrapperBitmap, width, height);
    pGraphics->DrawBitmap(&result, &rect);
    
#endif
}
Youlean is offline   Reply With Quote
Old 07-12-2016, 09:44 AM   #7
styro
Human being with feelings
 
Join Date: Feb 2014
Posts: 22
Default

It Worked!
somehow the colors where screwed so the red was black and so it was not possible to see something, noticed that today trying out things....
Thank You so much for Your Help!
all the best
styro
styro is offline   Reply With Quote
Old 07-12-2016, 10:26 AM   #8
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 367
Default

Quote:
Originally Posted by styro View Post
It Worked!
somehow the colors where screwed so the red was black and so it was not possible to see something, noticed that today trying out things....
Thank You so much for Your Help!
all the best
styro
Yes, MAC uses different color arrangement, that's why you where having the problems..
No problem..
Youlean is offline   Reply With Quote
Old 12-11-2016, 10:56 PM   #9
TBProAudio
Human being with feelings
 
TBProAudio's Avatar
 
Join Date: May 2014
Location: Germany
Posts: 304
Default

Quote:
Originally Posted by styro View Post
Hello!

i am trying to port the vsti that i made with VS2013 / Cairo / Gamma on win7
(and works quite nicely, many thanks to all of the forum for help&hints)
to osx. after setting up cairo thru macports and correcting some errors and setting the include-path /opt/local/include and linker to link to /opt/local/lib/libcairo.dylib it compiles, it links ... and it crashes instantly at scan :-(

so to test the cairo-install i builded the MyFirstCairoPlugin-example,
and it appears in reaper, but it shows only the knob (and some lice-text to test) but not the cairo-stuff (red-sine-line). (same thing when its build as AU)
i tryed linking with /opt/local/lib/libcairo.dylib,/opt/local/lib/libcairo.a and the stuff in /opt/local/lib/cairo.

when i test the generated MyFirstCairoPlugin.vst on a MacBook (Reaper64 on Maverics 64Bit) it crashes while scanning (and dont show up afterward),
other example-plugins run.

i am building as 64Bit vst2 with xcode 7.2.1 (with sdk 10.5 10.7 10.8 installed, building for 10.7) on a el capitain 64Bit install on VirtualBox (works quite nicely....).

so i would be very grateful for some wdl-ol wisdom....
did someone got cairo working on osx and how?
is the cairo-stuff linked statically to the plugin?
is there anything to take special care for porting to mac?
is there a way to debug the crashing while scanning the plugin,
like something like savihost on windows?

i am new to the xcode, is there some important hints?
many thanks for any help!

all the best
styro
Thank you for figuring this out. Are you able to provide the OSX libs and includes? thank you regards -tb
__________________
www.tb-software.com/TBProAudio
TBProAudio is offline   Reply With Quote
Old 12-12-2016, 03:14 AM   #10
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 367
Default

Quote:
Originally Posted by TBProAudio View Post
Thank you for figuring this out. Are you able to provide the OSX libs and includes? thank you regards -tb
I will post all macOS libs required for static linking later...
Youlean is offline   Reply With Quote
Old 12-12-2016, 10:47 AM   #11
TBProAudio
Human being with feelings
 
TBProAudio's Avatar
 
Join Date: May 2014
Location: Germany
Posts: 304
Default

Quote:
Originally Posted by Youlean View Post
I will post all macOS libs required for static linking later...
Thank you for your support, great!
__________________
www.tb-software.com/TBProAudio
TBProAudio is offline   Reply With Quote
Old 12-14-2016, 05:27 AM   #12
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 367
Default

Here are the libs
https://drive.google.com/file/d/0B1l...ew?usp=sharing
Youlean is offline   Reply With Quote
Old 12-14-2016, 10:42 PM   #13
TBProAudio
Human being with feelings
 
TBProAudio's Avatar
 
Join Date: May 2014
Location: Germany
Posts: 304
Default

Thank you!
__________________
www.tb-software.com/TBProAudio
TBProAudio is offline   Reply With Quote
Old 12-16-2016, 09:38 AM   #14
TBProAudio
Human being with feelings
 
TBProAudio's Avatar
 
Join Date: May 2014
Location: Germany
Posts: 304
Default

Quote:
Originally Posted by Youlean View Post
Again, thanks for this, but it seems, that the libs are compiled against latest SDK (10.9), correct? I'm getting some unresolved symbols because I'm still on 10.6...
__________________
www.tb-software.com/TBProAudio
TBProAudio is offline   Reply With Quote
Old 12-17-2016, 01:29 PM   #15
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 367
Default

Quote:
Originally Posted by TBProAudio View Post
Again, thanks for this, but it seems, that the libs are compiled against latest SDK (10.9), correct? I'm getting some unresolved symbols because I'm still on 10.6...
No, it was compiled with 10.11 + universal so it should work on 10.6 too. Did you add correctly all libs to a target? Screenshot or video would really help (if it is necessary just PM me)

EDIT - I have uploaded wrong libs. I will fix that later.

Last edited by Youlean; 12-17-2016 at 01:43 PM.
Youlean is offline   Reply With Quote
Old 12-17-2016, 11:58 PM   #16
TBProAudio
Human being with feelings
 
TBProAudio's Avatar
 
Join Date: May 2014
Location: Germany
Posts: 304
Default

Quote:
Originally Posted by Youlean View Post
...
EDIT - I have uploaded wrong libs. I will fix that later.
Ok, lets try with fixed libs. Thank you for your efforts:-)
__________________
www.tb-software.com/TBProAudio
TBProAudio is offline   Reply With Quote
Old 12-18-2016, 10:02 AM   #17
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 367
Default

Quote:
Originally Posted by TBProAudio View Post
Ok, lets try with fixed libs. Thank you for your efforts:-)
Try this libs:


You need to put it all in your project.

Last edited by Youlean; 02-25-2017 at 03:00 PM.
Youlean is offline   Reply With Quote
Old 12-18-2016, 10:34 AM   #18
TBProAudio
Human being with feelings
 
TBProAudio's Avatar
 
Join Date: May 2014
Location: Germany
Posts: 304
Default

Thank you for your efforts. But still no luck:

1) the new package seems to be incomplete, i.a. pixman lib is missing.
If i use the previous provided libs i get missing ref "___sincos_stret" which indicates obviously a compiler/SDK/OSX version mismatch.

2) Due to several reasons I'm still on OSX version 10.9.5.
Xcode is version 5.1.1
WDL-OL project config: BASE_SDK = macosx10.6 and MACOSX_DEPLOYMENT_TARGET = 10.5

In any case please to not waste your time with this quite old setup :-)
__________________
www.tb-software.com/TBProAudio
TBProAudio is offline   Reply With Quote
Old 01-06-2017, 01:23 PM   #19
Youlean
Human being with feelings
 
Youlean's Avatar
 
Join Date: May 2015
Location: Serbia
Posts: 367
Default

Quote:
Originally Posted by TBProAudio View Post
Thank you for your efforts. But still no luck:

1) the new package seems to be incomplete, i.a. pixman lib is missing.
If i use the previous provided libs i get missing ref "___sincos_stret" which indicates obviously a compiler/SDK/OSX version mismatch.

2) Due to several reasons I'm still on OSX version 10.9.5.
Xcode is version 5.1.1
WDL-OL project config: BASE_SDK = macosx10.6 and MACOSX_DEPLOYMENT_TARGET = 10.5

In any case please to not waste your time with this quite old setup :-)
OK. I finally got it. I had to compile everything manually. Here it is. This will work on 10.7 and later.

https://drive.google.com/file/d/0B1l...ew?usp=sharing
Youlean is offline   Reply With Quote
Old 01-06-2017, 11:35 PM   #20
TBProAudio
Human being with feelings
 
TBProAudio's Avatar
 
Join Date: May 2014
Location: Germany
Posts: 304
Default

Quote:
Originally Posted by Youlean View Post
OK. I finally got it. I had to compile everything manually. Here it is. This will work on 10.7 and later.

https://drive.google.com/file/d/0B1l...ew?usp=sharing
Thanks for this, i will test it asap :-)
__________________
www.tb-software.com/TBProAudio
TBProAudio is offline   Reply With Quote
Old 02-20-2017, 11:54 AM   #21
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 73
Default

Thanks for posting these libs, after a failed attempt at compiling them over here they've really helped get me going with Cairo!

Unfortunately still got a couple of issues with the Cairo_Teaser_001 project and getting it to compile on both Mac and Windows.

Firstly, my project compiles and runs fine as a 32bit/64bit standalone on Visual Studio 2015, though I get a lot of warnings similar to this: 'warning LNK4099: PDB 'vc140.pdb' was not found with 'cairo-static.lib(pixman.obj)' or at 'C:\wdl-ol\IPlugExamples\Compere\build-win\app\Win32\bin\vc140.pdb'; linking object as if no debug info

I've been using Ableton 64bit to test, but here the 64bit VST doesn't show up in the VST list, though it detects and runs fine in Reaper.


I'm less successful attempting to compile with XCode (running XCode 6.2)
I'm compiling with the Base SDK and deployment target set to 10.9. I get a few errors along the lines of "Apple Mach-O Linker (ld) Error "_BZ2_bzDecompress", referenced from:" and one stating "linker command failed with exit code 1". Not been able to figure out a way around this yet.

Any thoughts and solutions to these two problems would be greatly appreciated!
Bobflip is offline   Reply With Quote
Old 02-21-2017, 04:18 AM   #22
Bobflip
Human being with feelings
 
Join Date: Nov 2016
Posts: 73
Default

Ok, scratch the first bit. Up till now I had been coding on my laptop, but today I installed Windows 10 on my desktop machine. And my own Cairo project compiles as both standalone and as a 64bit vst*and Ableton detects and runs it fine! So I guess something got corrupted with my project that cleaning couldn't get rid of.

Bizarrely though, now the Teaser project won't compile as an app, only as a plugin. It's giving the following errors. I've downloaded the project afresh but it still gives the same errors, and I've no idea what I changed to cause this! app_main.obj is found in the folder that it's trying to compile to, so why's it no longer being linked?

Code:
Error LNK2019 unresolved external symbol __imp_InitCommonControls referenced in function WinMain Cairo_Teaser_001-app C:\wdl-ol\IPlugExamples\Cairo_Teaser_001 - Oli - Copy\app_main.obj 1
Severity Code Description Project File Line Suppression State
Error LNK1120 1 unresolved externals Cairo_Teaser_001-app C:\wdl-ol\IPlugExamples\Cairo_Teaser_001 - Oli - Copy\build-win\app\x64\bin\Cairo_Teaser_001.exe 1
And XCode is still being tricky. Tried a bunch of ideas but can't get the Teaser to compile at all there.
Bobflip is offline   Reply With Quote
Old 02-27-2017, 02:36 PM   #23
CaptnWillie
Human being with feelings
 
Join Date: Dec 2016
Posts: 41
Default

Posted in another thread, but hoping someone might be able to take a crack...

Ive gotten everything to compile, (linking the static libraries, making a control file, including the headers, etc)

but while my build succeeds, the app wont launch, (I haven't tried AU or VST yet), and if I try to launch the built app im getting "PowerPC applications are no longer supported"; is this to say that the Cairo library is depreciated?

When build succeeds, I am receiving "Found an unexpected Mach-O header code: 0x72613c21".

I have been following the examples laid out by wordpress above. Install macports, Install Cairo and dependencies with Macports, import everything via search and changed the Mach-O linker type to Static Library...

Also the AU builds, and will appear in Ableton, but will not launch! I am happy to do a screen recording if that is helpful.

Any help is appreciated!!
CaptnWillie is offline   Reply With Quote
Old 03-16-2017, 11:02 PM   #24
TBProAudio
Human being with feelings
 
TBProAudio's Avatar
 
Join Date: May 2014
Location: Germany
Posts: 304
Default

Quote:
Originally Posted by Youlean View Post
OK. I finally got it. I had to compile everything manually. Here it is. This will work on 10.7 and later.

https://drive.google.com/file/d/0B1l...ew?usp=sharing
OK, i finally got it to work: switching to BASE SDK 10.7 made it.
One drawback: RTAS on OSX will no longer work:-(

Thank you very much Youlean!
__________________
www.tb-software.com/TBProAudio
TBProAudio is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:26 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.