I'm trying to compile a file with the V8 the JavaScript Engine by Google. I installed scons and have compiled the V8 engine. But, here is where the problem lies, I stay in the V8 directory as they say and make a file named hello_world.cpp with the code:
#include <v8.h>
using namespace v8;
int main(int argc, char* argv[]) {
// Create a stack-allocated handle scope.
HandleScope handle_scope;
// Create a new context.
Persistent<Context> context = Context::New();
// Enter the created context for compiling and
// running the hello world script.
Context::Scope context_scope(context);
// Create a string containing the JavaScript source code.
Handle<String> source = String::New("'Hello' + ', World!'");
// Compile the source code.
Handle<Script> script = Script::Compile(source);
// Run the script to get the result.
Handle<Value> result = script->Run();
// Dispose the persistent context.
context.Dispose();
// Convert the result to an ASCII string and print it.
String::AsciiValue ascii(result);
printf("%s\n", *ascii);
return 0;
}
Then I compile using gcc hello_world.cpp -o libv8.a. But, when I compile it I get a skew of errors:
hello_world.cpp:1:16: error: v8.h: No such file or directory
hello_world.cpp:3: error: ‘v8’ is not a namespace-name
hello_world.cpp:3: error: expected namespace-name before ‘;’ token
hello_world.cpp: In function ‘int main(int, char**)’:
hello_world.cpp:8: error: ‘HandleScope’ was not declared in this scope
hello_world.cpp:8: error: expected `;' before ‘handle_scope’
hello_world.cpp:11: error: ‘Persistent’ was not declared in this scope
hello_world.cpp:11: error: ‘Context’ was not declared in this scope
hello_world.cpp:11: error: ‘context’ was not declared in this scope
hello_world.cpp:11: error: ‘Context’ is not a class or namespace
hello_world.cpp:15: error: ‘Context’ is not a class or namespace
hello_world.cpp:15: error: expected `;' before ‘context_scope’
hello_world.cpp:18: error: ‘Handle’ was not declared in this scope
hello_world.cpp:18: error: ‘String’ was not declared in this scope
hello_world.cpp:18: error: ‘source’ was not declared in this scope
hello_world.cpp:18: error: ‘String’ is not a class or namespace
hello_world.cpp:21: error: ‘Script’ was not declared in this scope
hello_world.cpp:21: error: ‘script’ was not declared in this scope
hello_world.cpp:21: error: ‘Script’ is not a class or namespace
hello_world.cpp:24: error: ‘Value’ was not declared in this scope
hello_world.cpp:24: error: ‘result’ was not declared in this scope
hello_world.cpp:30: error: ‘String’ is not a class or namespace
hello_world.cpp:30: error: expected `;' before ‘ascii’
hello_world.cpp:31: error: ‘ascii’ was not declared in this scope
hello_world.cpp:31: error: ‘printf’ was not declared in this scope
I don't get why it say V8.h is not declared. I already built it and I'm in its directory and I'm guessing if I get rid of that all the other errors will go away. Any suggestions?
i just believe you in that you are really inside the toplevel source directory (and since i do not have compiled v8 i only believe that libvp8.a is created in that toplevel directory):
% g++ -Iinclude hello_world.cpp -o hello_world libv8.a
it says "v8.h" is not declared because that file is inside the "include" directory and the preprocessor is not able to find it out of thin air.
furthermore: you are compiling a .cpp file with the C compiler instead of the C++ compiler.
you are using the '-o' flag wrong because it defines the name of the linked binary and thus needs a name, you do not want the output binary be named "libvp8.a"
Related
I tried to complile the main.c in Nuklear/demo/d3d11/ (https://github.com/Immediate-Mode-UI/Nuklear/tree/master/demo/d3d11) with gcc on the commend prompt, namely using
gcc main.c -luser32 -ldxguid -ld3d11
It works perfectly.
It works using the "build.bat" too.
However, when I tried to use any of these (also changed the file name to main.cpp if needed)
g++ main.c -luser32 -ldxguid -ld3d11
gcc main.cpp -luser32 -ldxguid -ld3d11
g++ main.cpp -luser32 -ldxguid -ld3d11
It produced a huge amount of "was not declared in this scope" errors.
In file included from main.c:30:
nuklear_d3d11.h: In function 'void nk_d3d11_render(ID3D11DeviceContext*, nk_anti_aliasing)':
nuklear_d3d11.h:101:5: error: 'ID3D11DeviceContext_IASetInputLayout' was not declared in this scope
nuklear_d3d11.h:102:5: error: 'ID3D11DeviceContext_IASetVertexBuffers' was not declared in this scope
nuklear_d3d11.h:103:5: error: 'ID3D11DeviceContext_IASetIndexBuffer' was not declared in this scope
nuklear_d3d11.h:104:5: error: 'ID3D11DeviceContext_IASetPrimitiveTopology' was not declared in this scope
nuklear_d3d11.h:106:5: error: 'ID3D11DeviceContext_VSSetShader' was not declared in this scope
nuklear_d3d11.h:107:5: error: 'ID3D11DeviceContext_VSSetConstantBuffers' was not declared in this scope
nuklear_d3d11.h:109:5: error: 'ID3D11DeviceContext_PSSetShader' was not declared in this scope
nuklear_d3d11.h:110:5: error: 'ID3D11DeviceContext_PSSetSamplers' was not declared in this scope
nuklear_d3d11.h:112:5: error: 'ID3D11DeviceContext_OMSetBlendState' was not declared in this scope
nuklear_d3d11.h:113:5: error: 'ID3D11DeviceContext_RSSetState' was not declared in this scope
nuklear_d3d11.h:114:5: error: 'ID3D11DeviceContext_RSSetViewports' was not declared in this scope
nuklear_d3d11.h:124:10: error: 'ID3D11DeviceContext_Map' was not declared in this scope; did you mean 'ID3D11DeviceContext'?
nuklear_d3d11.h:156:5: error: 'ID3D11DeviceContext_Unmap' was not declared in this scope; did you mean 'ID3D11DeviceContext'?
nuklear_d3d11.h:171:9: error: 'ID3D11DeviceContext_PSSetShaderResources' was not declared in this scope
nuklear_d3d11.h:172:9: error: 'ID3D11DeviceContext_RSSetScissorRects' was not declared in this scope
nuklear_d3d11.h:173:9: error: 'ID3D11DeviceContext_DrawIndexed' was not declared in this scope
In file included from D:/OtherProgramFiles/msys64/mingw64/include/winbase.h:2682,
from D:/OtherProgramFiles/msys64/mingw64/include/windows.h:70,
from main.c:7:
nuklear_d3d11.h: In function 'void nk_d3d11_resize(ID3D11DeviceContext*, int, int)':
nuklear_d3d11.h:205:19: error: 'ID3D11DeviceContext_Map' was not declared in this scope; did you mean 'ID3D11DeviceContext'?
nuklear_d3d11.h:208:9: error: 'ID3D11DeviceContext_Unmap' was not declared in this scope; did you mean 'ID3D11DeviceContext'?
nuklear_d3d11.h: In function 'nk_context* nk_d3d11_init(ID3D11Device*, int, int, unsigned int, unsigned int)':
nuklear_d3d11.h:444:5: error: 'ID3D11Device_AddRef' was not declared in this scope
nuklear_d3d11.h:466:10: error: 'ID3D11Device_CreateRasterizerState' was not declared in this scope
nuklear_d3d11.h:470:11: error: 'ID3D11Device_CreateVertexShader' was not declared in this scope
nuklear_d3d11.h:479:10: error: 'ID3D11Device_CreateInputLayout' was not declared in this scope
nuklear_d3d11.h:498:10: error: 'ID3D11Device_CreateBuffer' was not declared in this scope
nuklear_d3d11.h:502:11: error: 'ID3D11Device_CreatePixelShader' was not declared in this scope
nuklear_d3d11.h:517:10: error: 'ID3D11Device_CreateBlendState' was not declared in this scope
nuklear_d3d11.h:528:10: error: 'ID3D11Device_CreateBuffer' was not declared in this scope
nuklear_d3d11.h:538:10: error: 'ID3D11Device_CreateBuffer' was not declared in this scope
nuklear_d3d11.h:552:10: error: 'ID3D11Device_CreateSamplerState' was not declared in this scope
nuklear_d3d11.h: In function 'void nk_d3d11_font_stash_end()':
nuklear_d3d11.h:600:10: error: 'ID3D11Device_CreateTexture2D' was not declared in this scope
nuklear_d3d11.h:609:10: error: 'ID3D11Device_CreateShaderResourceView' was not declared in this scope; did you mean 'ID3D11ShaderResourceView'?
nuklear_d3d11.h:611:5: error: 'ID3D11Texture2D_Release' was not declared in this scope; did you mean 'ID3D11Texture2D'?
nuklear_d3d11.h: In function 'void nk_d3d11_shutdown()':
nuklear_d3d11.h:625:5: error: 'ID3D11SamplerState_Release' was not declared in this scope; did you mean 'ID3D11SamplerState'?
nuklear_d3d11.h:626:5: error: 'ID3D11ShaderResourceView_Release' was not declared in this scope; did you mean 'ID3D11ShaderResourceView'?
nuklear_d3d11.h:627:5: error: 'ID3D11Buffer_Release' was not declared in this scope
nuklear_d3d11.h:629:5: error: 'ID3D11BlendState_Release' was not declared in this scope; did you mean 'ID3D11BlendState'?
nuklear_d3d11.h:630:5: error: 'ID3D11PixelShader_Release' was not declared in this scope; did you mean 'ID3D11PixelShader'?
nuklear_d3d11.h:632:5: error: 'ID3D11VertexShader_Release' was not declared in this scope; did you mean 'ID3D11VertexShader'?
nuklear_d3d11.h:633:5: error: 'ID3D11InputLayout_Release' was not declared in this scope; did you mean 'ID3D11InputLayout'?
nuklear_d3d11.h:634:5: error: 'ID3D11RasterizerState_Release' was not declared in this scope; did you mean 'ID3D11RasterizerState'?
nuklear_d3d11.h:635:5: error: 'ID3D11Device_Release' was not declared in this scope
main.c: In function 'void set_swap_chain_size(int, int)':
main.c:89:9: error: 'ID3D11RenderTargetView_Release' was not declared in this scope; did you mean 'ID3D11RenderTargetView'?
main.c:91:5: error: 'ID3D11DeviceContext_OMSetRenderTargets' was not declared in this scope
main.c:93:10: error: 'IDXGISwapChain_ResizeBuffers' was not declared in this scope
main.c:106:10: error: 'IDXGISwapChain_GetBuffer' was not declared in this scope
main.c:109:10: error: 'ID3D11Device_CreateRenderTargetView' was not declared in this scope
main.c:112:5: error: 'ID3D11Texture2D_Release' was not declared in this scope; did you mean 'ID3D11Texture2D'?
main.c: In function 'int main()':
main.c:294:9: error: 'ID3D11DeviceContext_ClearRenderTargetView' was not declared in this scope
main.c:295:9: error: 'ID3D11DeviceContext_OMSetRenderTargets' was not declared in this scope
main.c:297:14: error: 'IDXGISwapChain_Present' was not declared in this scope; did you mean 'IDXGISwapChain'?
main.c:309:5: error: 'ID3D11DeviceContext_ClearState' was not declared in this scope
main.c:311:5: error: 'ID3D11RenderTargetView_Release' was not declared in this scope; did you mean 'ID3D11RenderTargetView'?
main.c:312:5: error: 'ID3D11DeviceContext_Release' was not declared in this scope; did you mean 'ID3D11DeviceContext'?
main.c:313:5: error: 'ID3D11Device_Release' was not declared in this scope
main.c:314:5: error: 'IDXGISwapChain_Release' was not declared in this scope; did you mean 'IDXGISwapChain'?
All four commends work if I replace main.c/main.cpp with a simple hello world script (in C, also in C++ if I add "-lstdc++").
I think all of the errors come from things in msys64\mingw64\include\d3d11.h. It may be a linking problem. But the headers are included correctly otherwise "gcc main.c" won't works. I also tried to use "extern "C" {}", but it also didn't work.
I have tried to use Visual Studio commend prompt, Visual Studio Code and commend prompt in Windows. All have the same result.
As I want to use C++ with Nuklear, how can I do it with g++?
I have a simple C++ program that imports cmath.
#include <cmath>
int main() {
return 0;
}
I'm trying to compile it using the following command.
clang++ -o test main.cpp -std=c++14
But, I get the following errors
In file included from main.cpp:2:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:317:9: error:
no member named 'signbit' in the global namespace
using ::signbit;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:318:9: error:
no member named 'fpclassify' in the global namespace
using ::fpclassify;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:319:9: error:
no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
~~^
/usr/local/include/math.h:749:12: note: 'finite' declared here
extern int finite(double)
^
In file included from main.cpp:2:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:320:9: error:
no member named 'isinf' in the global namespace
using ::isinf;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:321:9: error:
no member named 'isnan' in the global namespace
using ::isnan;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:322:9: error:
no member named 'isnormal' in the global namespace
using ::isnormal;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:323:9: error:
no member named 'isgreater' in the global namespace
using ::isgreater;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:324:9: error:
no member named 'isgreaterequal' in the global namespace
using ::isgreaterequal;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:325:9: error:
no member named 'isless' in the global namespace
using ::isless;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:326:9: error:
no member named 'islessequal' in the global namespace
using ::islessequal;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:327:9: error:
no member named 'islessgreater' in the global namespace
using ::islessgreater;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:328:9: error:
no member named 'isunordered' in the global namespace
using ::isunordered;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:329:9: error:
no member named 'isunordered' in the global namespace
using ::isunordered;
~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:335:9: error:
no member named 'abs' in the global namespace; did you mean 'fabs'?
using ::abs;
~~^
/usr/local/include/math.h:417:15: note: 'fabs' declared here
extern double fabs(double);
^
In file included from main.cpp:2:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:640:26: error:
no template named 'numeric_limits'
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:640:60: error:
no template named 'numeric_limits'
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:641:18: error:
no template named 'numeric_limits'
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:641:50: error:
no template named 'numeric_limits'
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:646:17: error:
no template named 'numeric_limits'
static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Here are my system specifications.
macOS Catalina Version 10.15.2
Apple clang version 11.0.3 (clang-1103.0.32.29)
Xcode Version 11.4 (11E146) (not sure if this matters)
Thanks for any assistance!
EDIT: Updated to macOS 10.15.4 and Xcode 11.4.1 and still have the same issue
I believe this is answered at Catalina C++: Using <cmath> headers yield error: no member named 'signbit' in the global namespace
The easiest solution seems to be to uninstall the Command Line Tools, which works on Catalina, but I was hitting this on High Sierra, where I resorted to editing /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cmath
to comment out #include <math.h> and replace it with:
#include</Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h>
I had to do this to get homebrew's Rust (rustc-1.53.0) to compile on High Sierra. Probably a better approach would be to tell cmake:
set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk)
since it's not usually a great idea to mess with the system-supplied headers.
I have written a simple jiffies code and when I try to do rmmod I get
ERROR: Removing 'jiffi_module': Device or resource busy
so I did bit of research and found by doing lsmod below symptom of "permanent" being the problem which is caused by exit_function not being found.
Module Size Used by
jiffi_module 1027 0 **[permanent]**
infact my make file do show me warning related to exit function
Warning when exit function is defined as
static void __exit
jif_exit(void)
{
remove_proc_entry("jif", NULL);
}
warning: data definition has no type or storage class
warning: type defaults to ‘int’ in declaration of ‘modile_exit’
warning: parameter names (without types) in function declaration
warning: ‘jif_exit’ defined but not used
when I remove the __exit seems it atleast identifies jif_exit - so now the warning I get is
warning: data definition has no type or storage class
warning: type defaults to ‘int’ in declaration of ‘modile_exit’
warning: parameter names (without types) in function declaration
Reading through below Why is this kernel module marked at permanent on 2.6.39
it talks about gcc mismatch being a problem ? Can someone please help I am not able to debug it further ? Any pointers how to load module properly such that its not permanent?
Kernel module is marked as permanent (cannot be unloaded) if there is no exit function is defined for it.
exit function accepts no arguments and return nothing and should be defined either with predefined name
void cleanup_module(void)
{
...
}
or with arbitrary name but registered with module_exit macro
void <func_name>(void)
{
...
}
module_exit(<func_name>);
static, __exit and other attributes for exit function are optional.
I'm using gcc.
I want to create a queue of my own datatype.
In the following code, when I declare struct outside main(), it works fine but it gives compile-time errors when that struct is defined inside.
#include <queue>
using namespace std;
int main()
{
struct tempPos {int a; int b;}; //....(1)
queue<tempPos> b; //works only if tempPos is defined outside main
queue<int> x; //works fine anyways
return 0;
}
Following are the errors.
test.cpp: In function ‘int main()’:
test.cpp:10:15: error: template argument for ‘template<class _Tp> class std::allocator’ uses local type ‘main()::tempPos’
test.cpp:10:15: error: trying to instantiate ‘template<class _Tp> class std::allocator’
test.cpp:10:15: error: template argument 2 is invalid
test.cpp:10:18: error: invalid type in declaration before ‘;’ token
Compilation failed.
C++ forbids using locally-defined classes with templates because they have no linkage. The standard says:
14.3.1/2: .A local type, a type with no linkage, an unnamed type or a type compounded from any of these types shall not be used as a template-argument for a template type-parameter.
I've found a strange problem during the compile of an example of ffmpeg in Qt Mac.
I have installed the ffmpeg library and I have tested the examples of this with cc and gcc compiler on the terminal, and I don't have any problem in the case of compile and run.
But when I call the library (ffmpeg are C library) in Qt for compile the same code of the example, the g++ compiler give me many error.
I have used this structure in the main.cpp code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
extern "C" {
#include <libavutil/imgutils.h>
#include <libavutil/samplefmt.h>
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
}
#include <QDebug>
and the Compile Output gives me:
In file included from ../audvid/main.cpp:7:
/opt/local/include/libavutil/timestamp.h: In function 'char*
av_ts_make_string(char*, int64_t)':
/opt/local/include/libavutil/timestamp.h:48: warning: comparison
between signed and unsigned integer expressions
/opt/local/include/libavutil/timestamp.h:49: error: expected `)'
before 'PRId64' /opt/local/include/libavutil/timestamp.h:49: warning:
spurious trailing '%' in format
/opt/local/include/libavutil/timestamp.h:49: warning: too many
arguments for format /opt/local/include/libavutil/timestamp.h: At
global scope: /opt/local/include/libavutil/timestamp.h:68: error:
'AVRational' has not been declared
/opt/local/include/libavutil/timestamp.h: In function 'char*
av_ts_make_time_string(char*, int64_t, int*)':
/opt/local/include/libavutil/timestamp.h:70: warning: comparison
between signed and unsigned integer expressions
/opt/local/include/libavutil/timestamp.h:71: error: 'av_q2d' was not
declared in this scope ../audvid/main.cpp: In function 'int
decode_packet(int*, int)': ../audvid/main.cpp:50: error: cannot
convert 'AVRational*' to 'int*' for argument '3' to 'char*
av_ts_make_time_string(char*, int64_t, int*)' ../audvid/main.cpp:73:
error: cannot convert 'AVRational*' to 'int*' for argument '3' to
'char* av_ts_make_time_string(char*, int64_t, int*)'
../audvid/main.cpp:75: error: 'struct AVFrame' has no member named
'channels' ../audvid/main.cpp:84: error: 'struct AVFrame' has no
member named 'channels' ../audvid/main.cpp:90: error: 'struct AVFrame'
has no member named 'channels' ../audvid/main.cpp: In function 'int
open_codec_context(int*, AVFormatContext*, AVMediaType)':
../audvid/main.cpp:112: error: 'av_get_media_type_string' was not
declared in this scope ../audvid/main.cpp:123: error:
'av_get_media_type_string' was not declared in this scope
../audvid/main.cpp:129: error: 'av_get_media_type_string' was not
declared in this scope ../audvid/main.cpp: In function 'int
get_format_from_sample_fmt(const char**, AVSampleFormat)':
../audvid/main.cpp:152: warning: comparison between signed and
unsigned integer expressions ../audvid/main.cpp: In function 'int
main(int, char**)': ../audvid/main.cpp:239: error: invalid conversion
from 'void*' to 'uint8_t**' make: *** [main.o] Error 1 make: Leaving
directory
`/Users/polin/Desktop/audvid/audvid-build- Qt_4_8_0_qt_everywhere_opensource_src_4_8_0_tp-Release'
10:44:37: The process "/usr/bin/make" exited with code 2. Error while
building/deploying project audvid (target: Qt 4.8.0
(qt-everywhere-opensource-src-4.8.0-tp)) When executing step 'Make'
I don't understand if I make a mistake in the code or if I must change the Qt compiler? (and I don't know how can do this)
You need to include libavutil/avutil.h before #include <libavutil/imgutils.h>. Also you need to add #include <libavcodec/avcodec.h>
Because ffmpeg is written in pure C. Some C99 design is incompatible with g++ compiler. So one way to solve it is to find where the "wrong" source codes are and replace them with C++ design style.
e.g.
av_get_bytes_per_sample( static_cast<AVSampleFormat>(format) )
#undef av_err2str
#define av_err2str(errnum) \
av_make_error_string((char*)__builtin_alloca(AV_ERROR_MAX_STRING_SIZE), AV_ERROR_MAX_STRING_SIZE, errnum)
#undef av_ts2timestr
#define av_ts2timestr(ts, tb) \
av_ts_make_time_string((char*)__builtin_alloca(AV_TS_MAX_STRING_SIZE), ts, tb)