[Cs-dev] CsoundAPI Static Linking
Date | 2012-11-22 10:03 |
From | Gaebalsa |
Subject | [Cs-dev] CsoundAPI Static Linking |
Attachments | None None |
Hello Csounder, I compiled examples of "Audio Programming Book"'s DVD chapter 35 Csound Host API with Xcode 4.5.2. Most examples works fine with CsoundLib.framework Now, I am trying to compile same examples with static linking. I compiled "libcsound.a" from csound5 source code(in IOS folder) and link this .a file to example project.(i386, armv7, arrmv7s.. I also want to know how to build this library with other architecture such as x86_64) Build succeeded, but there is error "Error opening plugin directory '/usr/local/lib/csound/plugins': No such file or directrror opening plugin directory '/usr/local/lib/csound/plugins': No such file or directory[m [" I made directory csound/plugins.. and error portaudio... then I put libporttaudio.a but does not work.. I do not know where I am... Actually, It is my first step to use CsoundAPI and I even do not know what I do not know... So, my question is how to make static link with Xcode and I am happy to listen any advice. I hope to hear from you!!! Thank you in advance.. happy thanks giving. ~GB |
Date | 2012-11-22 12:26 |
From | Steven Yi |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Hi Gaebalsa, It's interesting that you are using the iOS build to link for Desktop, as you can just use the normal desktop build too. But if you want to modify the iOS build to build for x86_64, you can add that to the ARCHS and VALID_ARCHS list in csound/iOS/simulator.xcconfig. i.e.: ARCHS = i386 x86_64 VALID_ARCHS = i386 x86_64 The iOS build builds twice, once for simulator and once for devices. The iOS simulator is done in i386, so that is why that is the only one in the simulator config. For devices, we build for armv6, armv7, and armv7s, and listing those architectures there gets xcodebuild to do all of them at once. Hope that helps! steven On Thu, Nov 22, 2012 at 10:03 AM, Gaebalsa |
Date | 2012-11-22 18:33 |
From | Gaebalsa |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Thank you for your prompt reply. I will modify the .xcconfig and try again. by the way, is there any other way I can build static library for desktop? easier or efficient way to build? ~GB On Nov 22, 2012, at 4:26 AM, Steven Yi |
Date | 2012-11-22 23:10 |
From | Steven Yi |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Hi GB, To build a static library for Desktop, you can use: scons dynamicCsoundLibrary=0 (It should default to that though too.) For Csound5, we use scons to build. You could also use CMake to build a static library if you're familiar with it by creating a directory to build in (i.e. "cs5make"), then in that folder use: cmake ../csound5 BUILD_STATIC_LIBRARY=1 -g Xcode that will create an XCode project that you can use to build libcsound.a. Otherwise, scons should be easy enough to use. steven On Thu, Nov 22, 2012 at 6:33 PM, Gaebalsa |
Date | 2012-11-23 07:45 |
From | Gaebalsa |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Attachments | None None |
Great!! Thank you. It works!! I built libcsound64.a(4.1MB) and libcsound.a(4MB) file, using Cmake. Now I want to build simple Application with the Csound Host API, linking statically. I created new Xcode project and put example2.c and example2.csd from DVD chapter 35 and libcsound.a which I built. I got this error message. ================================================================ ld: warning: ld: warning: ignoring file /Users/myusrname/Desktop/cSoundAPI/cSoundAPI/libs/libcsound64.a, file was built for archive which is not the architecture being linked (i386): /Users/myusrname/Desktop/cSoundAPI/cSoundAPI/libs/libcsound64.aignoring file /Users/myusrname/Desktop/cSoundAPI/cSoundAPI/libs/libcsound.a, file was built for archive which is not the architecture being linked (i386): /Users/myusrname/Desktop/cSoundAPI/cSoundAPI/libs/libcsound.a Undefined symbols for architecture i386: "_csoundCompile", referenced from: _main in example2.o "_csoundCreate", referenced from: _main in example2.o "_csoundDestroy", referenced from: _main in example2.o "_csoundGetChannelPtr", referenced from: _main in example2.o "_csoundInitialize", referenced from: _main in example2.o "_csoundPerformKsmps", referenced from: _main in example2.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) ================================================================ I think I built the library for both i386 and x86_64. BEST, ~GB On Nov 22, 2012, at 3:10 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi GB, |
Date | 2012-11-23 10:30 |
From | Rory Walsh |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
I'm no OSX expert, but it looks like the library you built was targeted for a different architecture. Did you say something about the iOS build yesterday, perhaps there is some confusion there, or maybe you specified the wrong flag when running cmake? I'm not sure. Victor or Steven should be able to point you in the right direction. On 23 November 2012 07:45, Gaebalsa |
Date | 2012-11-23 19:57 |
From | Steven Yi |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Ah, I forgot that the CMake files are setup for just default architecture. You can try using: cmake ../csound6 -G Xcode -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" or modifying the XCode project settings for the libcsound target manuall in the generated xcode project. On Fri, Nov 23, 2012 at 7:45 AM, Gaebalsa |
Date | 2012-11-23 22:44 |
From | Gaebalsa |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
It complete to compile the libraries and .c file. There is new error message both Xcode and Terminal. ======================Error Message=============================== Error opening plugin directory '/usr/local/lib/csound/plugins': No such file or directory ======================End of Error Message========================== It is what I typed in Terminal. I may have very simple and basic mistake…. gcc example2.c /Users/user/Desktop/cSoundAPI/cSoundAPI/libs/libcsoundbuildagain.a /Users/user/Desktop/cSoundAPI/cSoundAPI/libs/libsndfilex86_64.a -o example2 -I/Users/user/Desktop/cSoundAPI/cSoundAPI/include Or It still need libraries or plugins for run this Host app without csound installation. I am really thank you for your help and hope to hear from you again. Best, ~GB On Nov 23, 2012, at 11:57 AM, Steven Yi |
Date | 2012-11-23 22:57 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Set your OPCODEDIR and OPCODEDIR64 environment variables to point to where the plugins are, or make them empty On 23 Nov 2012, at 22:44, Gaebalsa wrote: > It complete to compile the libraries and .c file. There is new error message both Xcode and Terminal. > > ======================Error Message=============================== > > Error opening plugin directory '/usr/local/lib/csound/plugins': No such file or directory > > ======================End of Error Message========================== > > It is what I typed in Terminal. I may have very simple and basic mistake…. > > gcc example2.c /Users/user/Desktop/cSoundAPI/cSoundAPI/libs/libcsoundbuildagain.a /Users/user/Desktop/cSoundAPI/cSoundAPI/libs/libsndfilex86_64.a -o example2 -I/Users/user/Desktop/cSoundAPI/cSoundAPI/include > > Or It still need libraries or plugins for run this Host app without csound installation. > > I am really thank you for your help and hope to hear from you again. > > Best, > > ~GB > > > > > > > On Nov 23, 2012, at 11:57 AM, Steven Yi |
Date | 2012-11-23 23:52 |
From | Gaebalsa |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
When I build the csound library from csound5 source code and "sudo make install" the "csound/plugins-5.2" folder automatically created and filled with a bunch of plugins. The application works fine with this plugins folder (I just change the folder name plugins 5.2 to plugins).. However, my goal is about running application without installing csound. So, I built Csound static library and compiled the example2.c from "audio programming book DVD chapter 35" with this static library. Now, I move compiled example2 application to another machine which is not install csound and tried to execute this. But, it gave me a line of error message. ======error message ========== Error opening plugin directory '/usr/local/lib/csound/plugins': No such file or directory). ======End of error message======= So I also copied "usr/local/lib/csound/plugins" folder to new machine with plugins and executed it. It gave me another error message. ======= error message======================================== Csound version 5.18.02 (float samples) Nov 23 2012 WARNING: could not open library '/usr/local/lib/csound/plugins/csladspa.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libampmidid.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libcellular.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libcmidi.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libcontrol.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libcs_date.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libdoppler.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libfareygen.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libfractalnoise.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libimage.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libjacko.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libjackTransport.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libmixer.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libosc.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libpmidi.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libpy.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/librtauhal.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/librtjack.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/librtpa.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libscansyn.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libsignalflowgraph.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libstdutil.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libsystem_call.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libudprecv.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libudpsend.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libvirtual.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libwidgets.dylib' (-1) WARNING: could not open library '/usr/local/lib/csound/plugins/libwiimote.dylib' (-1) UnifiedCSD: /Users/user/Desktop/example2.csd Creating options Creating orchestra Creating score Parsing successful! Elapsed time at end of orchestra compile: real: 0.003s, CPU: 0.003s Sorting score Elapsed time at end of score sort: real: 0.003s, CPU: 0.003s displays suppressed 0dBFS level = 32768.0 orch now loaded audio buffered in 1024 sample-frame blocks *** error: unknown rtaudio module: 'PortAudio' Failed to initialise real time audio output inactive allocs returned to freespace end of score. overall amps: 0.0 overall samples out of range: 0 1 errors in performance Elapsed time at end of performance: real: 0.003s, CPU: 0.003s users-MacBook-Pro:Desktop user$ ============End of Error message===================================== Now... I do not know what I don't know again... :). Your comment and advice will really help me overcome this.... situation... Thank you again all csounders!!!! Have a great day!!! Best, ~GB On Nov 23, 2012, at 2:57 PM, Victor Lazzarini |
Date | 2012-11-24 08:06 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Is this other machine different (e.g. OS version, CPU type, etc)? There is some incompatibility between the plugins and the executable, so the plugins cannot be loaded. For instance if your plugins are only i386 and your executable universal (i386 - x86_64), this could have happened if the the two OS are different versions (10.5 and 10.6) On 23 Nov 2012, at 23:52, Gaebalsa wrote: > > When I build the csound library from csound5 source code and "sudo make install" the "csound/plugins-5.2" folder automatically created and filled with a bunch of plugins. > > The application works fine with this plugins folder (I just change the folder name plugins 5.2 to plugins).. However, my goal is about running application without installing csound. > > So, I built Csound static library and compiled the example2.c from "audio programming book DVD chapter 35" with this static library. > > Now, I move compiled example2 application to another machine which is not install csound and tried to execute this. > > But, it gave me a line of error message. > > ======error message ========== > > Error opening plugin directory '/usr/local/lib/csound/plugins': No such file or directory). > > ======End of error message======= > > > So I also copied "usr/local/lib/csound/plugins" folder to new machine with plugins and executed it. It gave me another error message. > > ======= error message======================================== > > Csound version 5.18.02 (float samples) Nov 23 2012 > WARNING: could not open library '/usr/local/lib/csound/plugins/csladspa.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libampmidid.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libcellular.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libcmidi.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libcontrol.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libcs_date.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libdoppler.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libfareygen.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libfractalnoise.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libimage.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libjacko.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libjackTransport.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libmixer.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libosc.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libpmidi.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libpy.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/librtauhal.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/librtjack.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/librtpa.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libscansyn.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libsignalflowgraph.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libstdutil.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libsystem_call.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libudprecv.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libudpsend.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libvirtual.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libwidgets.dylib' (-1) > WARNING: could not open library '/usr/local/lib/csound/plugins/libwiimote.dylib' (-1) > UnifiedCSD: /Users/user/Desktop/example2.csd > Creating options > Creating orchestra > Creating score > Parsing successful! > Elapsed time at end of orchestra compile: real: 0.003s, CPU: 0.003s > Sorting score > Elapsed time at end of score sort: real: 0.003s, CPU: 0.003s > displays suppressed > 0dBFS level = 32768.0 > orch now loaded > audio buffered in 1024 sample-frame blocks > *** error: unknown rtaudio module: 'PortAudio' > Failed to initialise real time audio output > inactive allocs returned to freespace > end of score. overall amps: 0.0 > overall samples out of range: 0 > 1 errors in performance > Elapsed time at end of performance: real: 0.003s, CPU: 0.003s > users-MacBook-Pro:Desktop user$ > > ============End of Error message===================================== > > Now... I do not know what I don't know again... :). > > Your comment and advice will really help me overcome this.... situation... > > Thank you again all csounders!!!! > > Have a great day!!! > > Best, > > ~GB > > > > On Nov 23, 2012, at 2:57 PM, Victor Lazzarini |
Date | 2012-11-24 08:20 |
From | Gaebalsa |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Both machines are Mac OSX 10.8.2. and I compiled the static library with a command below. "cmake ../csound5 -G Xcode -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" . Only difference between two computer is whether Csound is installed. By the way, do I need to copy the plugins folder to other machine, too? I do not know what I am missing... May be I have missed really basic and simple thing... Best, ~GB On Nov 24, 2012, at 12:06 AM, Victor Lazzarini |
Date | 2012-11-24 10:04 |
From | Justin Smith |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Attachments | None None |
The plugins are loaded at runtime, even if csound itself is statically compiled. So yes, you do need the plugins directory to exist on the machine that is running the executable.
On Sat, Nov 24, 2012 at 12:20 AM, Gaebalsa <gaebalsa@gmail.com> wrote: Both machines are Mac OSX 10.8.2. and I compiled the static library with a command below. |
Date | 2012-11-24 13:09 |
From | Steven Yi |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Hi GB and all, A couple of things: first is, unlike the SCons build, the CMake one was not setting the default OPCODEDIR to the folder in /Library/Frameworks. I have fixed that for cs5 and cs6 (now in GIT). For GB's issue, with libcsound.a you get a pretty full set of opcodes and a working csound engine, same as you get with iPhone. However, you don't get audio I/O out of the box. This is because we have plugins for audio I/O. What you're seeing when you run is that, by default, the driver for audio is set to use PortAudio, but that plugin can not be found. You can remedy this one of two ways: 1. Package the opcodes library directory with your application, then set OPCODEDIR (or OPCODEDIR64) to that folder. I don't recall the code to find the directory where your .app is installed, but it should be easy to search online. 2. You can do what the iOS build does, which is explicitly set the rtaudio plugin to null to tell Csound not to use a plugin for audio, then handle taking the audio generated from Csound and output to CoreAudio yourself. I think the code in the iOS build (look at CsoundObj.m) might be able to work as-is. (Which makes me wonder too, if CsoundObj is usable as-is for desktop applications.) Hope that helps! steven On Sat, Nov 24, 2012 at 8:20 AM, Gaebalsa |
Date | 2012-11-24 20:30 |
From | Gaebalsa |
Subject | Re: [Cs-dev] CsoundAPI Static Linking |
Great Thank you. You make it clear. I will try to build the desktop app with 2nd option.. It looks worth wasting my time~ :) Thank you csounders! I appreciate your kind answers. I may get back here soon with another issues! Have a great weekend! BEST, ~GB On Nov 24, 2012, at 5:09 AM, Steven Yi |