# Custom CFLAGS in projucer

**URL:** <https://forum.juce.com/t/custom-cflags-in-projucer/18957>\
**Category:** The Projucer\
**Created:** [September 4, 2016, 1:52pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957 "2016-09-04T13:52:33Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [September 4, 2016, 1:52pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/1 "2016-09-04T13:52:33Z")

</div>

Hi everybody,

I am trying to integrate ffmpeg into a juce project. For FFmpeg I need to write a C-wrapper, because it won’t link with the C++ name mangeling (also not with extern “C”).  
So I have a c file which needs to get an additional include path. But the compiler flags in the projucer are only put into the “Other C++ flags” in XCode, the “Other C-Flags” remains empty. So after each save of the projucer I have to add the CFlags manually.

Could we either have an extra C-Flags field or the C++Flags could go into both fields, at least the -I flags?  
Or is there a method I am not aware of?

Thanks for your thoughts  
Daniel

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [September 4, 2016, 6:16pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/2 "2016-09-04T18:16:21Z")

</div>

> [@daniel](#):
>
> For FFmpeg I need to write a C-wrapper, because it won’t link with the C++ name mangeling (also not with extern “C”).

That seems odd to me. In a personal project, I use JUCE and ffmpeg a lot and I don’t need to write a c wrapper. In my C++/JUCE file, I simply include the ffmpeg headers like this:

```
extern "C" {                                                                    
    #include "libavformat/avformat.h"                                               
    #include "libavformat/avio.h"                                                   
    #include "libavfilter/avfilter.h"                                               
    #include "libavfilter/buffersink.h"                                             
    #include "libavfilter/buffersrc.h"                                              
    #include "libavutil/common.h"                                                   
    #include "libavutil/opt.h"                                                      
}   

```

> [@daniel](#):
>
> Or is there a method I am not aware of?

You could use the `Extra compiler flags` field in the Projucer and then specify the include paths like you would on the command line to the compiler:

 ![](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/c/c554915a5c052aad7e45268f46d356c1c267e97d.png)

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [September 4, 2016, 6:21pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/3 "2016-09-04T18:21:13Z")

</div>

Yes, that’s exactly what I did, it compiles well, but the linker doesn’t find the symbols, it says “No symbols for the architecture x86\_64”…  
Now I put all ffmpeg calls and includes in a .c file and all works well. Just that the Extra Compiler flags are not used when compiling the C file. They are only used when cpp files are compiled. That’s why I need to copy the -I…/ffmpeg/include in XCode into the “Other C-flags” field…

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [September 4, 2016, 6:25pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/4 "2016-09-04T18:25:43Z")

</div>

Which OS are you on. My code snippet works fine on both linux and OS X. Are you linking to the static or to the dynamic libavcodec? Are you sure you are compiling ffmpeg for x86\_64?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [September 4, 2016, 6:34pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/5 "2016-09-04T18:34:09Z")

</div>

Here are my settings:

 ![](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/a/a1b2fd58874553efc1aaa5c3f803480f56153a7b.png)  
…which results in these XCode settings:  
 ![](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/0/027464714d5bcde996104522ed7403f24e11ec53.png)

As it works with no other changes when I link the C-file I think it shouldn’t be related, should it?  
I tried first using shared because of licensing, but when it did not work I configured ffmpeg to build both and didn’t specify anything, so IIRC the default is still shared.

I’m on OSX 10.10.5 running xcode 7.2.1 and made sure ffmpeg was also compiled using CC not gcc.  
My configure for ffmpeg:

```
./configure --prefix=../build/darwin/ --enable-shared

```

Thanks for your time…

---

<div class="post-metadata">

**Author:** ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)\
**Post date:** [September 5, 2016, 6:16am UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/6 "2016-09-05T06:16:37Z")

</div>

For OS X you can add C flags by using the Xcode flags field in each configuration in projucer, just add **OTHER\_CFLAGS=-I…/ffmpeg/include**

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [September 5, 2016, 2:01pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/7 "2016-09-05T14:01:53Z")

</div>

Hi Anthony, thanks for the tip. But which field in projucer do you mean with “XCode flags field”?  
As I wrote before, the Extra compiler flags are only set into XCodes “Other C++ Flags”, the “Other C-Flags” stays empty.  
Or do I have to modify an exporter file?

---

<div class="post-metadata">

**Author:** ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)\
**Post date:** [September 5, 2016, 3:44pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/8 "2016-09-05T15:44:01Z")

</div>

If you click on the configuration (i.e. debug, release, etc.) of an Xcode exporter in the projucer there is a field called _“Custom Xcode flags”_ this allows you to set _any_ xcode flags of a project, if you ever need to know what the flag name is in Xcode view your build settings and goto _Editor \>\> Show Setting Names_ (if it says _“Show Setting Titles”_ you don’t need to change anything).

Hope that helps.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [September 5, 2016, 4:15pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/9 "2016-09-05T16:15:08Z")

</div>

Ah ok, I looked only on the general page where the settings for all configurations are. And even then I had to look three times, I would never have found it myself. Thanks a million!

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [September 5, 2016, 4:57pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/10 "2016-09-05T16:57:24Z")

</div>

Really strange. I just made a project from scratch again and it works without any problems. This is how I configured ffmpeg:

```
./configure --disable-gpl --disable-static --enable-shared
```

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [September 5, 2016, 8:47pm UTC](https://forum.juce.com/t/custom-cflags-in-projucer/18957/11 "2016-09-05T20:47:10Z")

</div>

I have a thought, eventually it has something to do with deployment targets and such. I usually set in Projucer/XCode 10.7 and C++11… maybe I need to configure ffmpeg the same…  
I do this, since XCode keeps compiling for 10.11 on my 10.10, so I would not be able to run my own code…  
For today my brains and my laptops batteries are too low…
