I am trying to compile (IDE:VS2008) the following project:
https://github.com/arpu/adscanner
As the project needs the ffmpeg libaries, I've downloaded the DEV version from here: http://ffmpeg.zeranoe.com/builds/
I've linked the library directions and added the headers to the include path.
Though I get the error message: ""ffmpeg/avcodec.h": No such file or directory"
Thank you in advance
PS: I've tried both the 64bit and 32bit library, neither worked. But how can I figure it out weather the github project is using the 32bit or 64bit ffmpeg version?
Change this in ffmpeg_movie.h
extern "C" {
#include <ffmpeg/avcodec.h>
#include <ffmpeg/avformat.h>
#include <ffmpeg/swscale.h>
}
to this
extern "C"{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
and when i last used ffmpeg i had to add this
extern "C"{
#ifdef __cplusplus
#define __STDC_CONSTANT_MACROS
#ifdef _STDINT_H
#undef _STDINT_H
#endif
# include <stdint.h>
#endif
}
# include <stdio.h>
#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif
Related
I want to compile a simple test project for a library that makes use of a ftd2xx driver. I already compiled it successfully on linux and I'm trying to do the same on Windows. The main difference are some minor modification to the library.
The test file I want to compile is this:
//#include "HPX-linux.h"
#include "HPX-Windows.h"
#include <stdlib.h>
#include <stdio.h>
int main(){
int devs;
getSerialNum(&devs);
printf("%d\n\n", devs);
simpleTest("./myTest/");
return 0;
}
And the preprocessing directives of HPX-Windows.h are as follows:
#ifndef HPXLINUX_H
#define HPXLINUX_H
#include <math.h>
#include <stdint.h>
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include "ftd2xx.h"
#include <pthread.h>
// typedefs
//typedef uint16_t DWORD;
#ifndef __cplusplus
typedef uint8_t bool;
#endif
// static const defines
#ifndef __cplusplus
#define TRUE 1
#define FALSE 0
#endif
#define SUCCESS 0
#define FAILURE -1
#define RETRIEDTOOMANY -10
#define LOSTHEADFRAME -11
#define GOTAV 2
#ifdef __unix__
#define PRELIB extern
#elif _WIN32
#ifdef ADD_EXPORTS
#define PRELIB __declspec(dllexport)
#else
#define PRELIB __declspec(dllimport)
#endif
#endif
#ifdef __unix__
#define CALL
#elif _WIN32
#define CALL __cdecl
#endif
About ftd2xx, I have 2 .h headers, a .lib and a .dll.
With the driver properly installed, I could compile the library on linux with:
gcc -o test test.c -Wall -Wextra -lHPX-linux -lftd2xx -lm
I'm using MinGW on Windows. The command I'm using is:
gcc test.c HPX-Windows.c -L -lftd2xx -g
And then I get a list of errors type "undefined reference to _imp__*", being * a function. I expected them to be the functions of ftd2xx.h, but it also happens to function declared in HPX-Windows.h, including getSerialNum and simpleTest. Why does it happen when I'm using a .c source file instead of a library?
The error is caused by symbols exported with __declspec(dllimport) in header files that can't be imported from a shared library (.DLL).
I would recommend creating a libftd2xx.dll.a file from the ftd2xx.dll file and linking with that (e.g. if the files are in the current directory using -L. -lftd2xx.dll).
Or you could probably just link with the .dll file by specifying it in the gcc command, something like this: gcc -o test.exe test.c HPX-Windows.c ftd2xx.dll -g).
If that doesn't work check ftd2xx.h to see where __declspec(dllimport) is imported and see if you can set a define that causes the header to not use __declspec(dllexport)/__declspec(dllimport) and link with your lib file in case it's a static library (something like: gcc --static -o test.exe test.c HPX-Windows.c -L. -lftd2xx -g).
I am trying to run the make file of some application. The source code is
INCL= -I/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/GLUT.framework/Versions/A/Headers
LIBD= -L/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries
evmovie: evmovie.c
cc evmovie.c -o evmovie $(INCL) $(LIBD) -framework GLUT -lGL -lGLU
When I run it in the terminal, it gives me a lot of warnings. The majority of them are saying a lot of glut function is deprecated since Mac OS 10.9. I just ignore them. However, one of the crucial errors is the following.
directory not found for option '-L/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries'
ld: library not found for -lGL
I do not not know how to fix this. Can anyone help me?
By the way, the source code of evmovie.c is
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#if defined(WIN32) || defined(_WIN32)
#include <GLUT/glut.h>
#include <windows.h>
#include <io.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#define __cdecl
#define _fileno fileno
int _filelength(int fd)
{ struct stat statbuf;
fstat(fd,&statbuf);
return statbuf.st_size;
}
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
// unix, linux
#include <GL/glut.h>
#endif
#endif
Visual Studio defines _byteswap_uint64 and _byteswap_ulong in stdlib.h.
Am I right to assume, that this is not standard and won't compile on Linux or Darwin?
Is there a way to define these includes in a cross-platform way?
Google's CityHash source code uses this code:
https://github.com/google/cityhash/blob/8af9b8c2b889d80c22d6bc26ba0df1afb79a30db/src/city.cc#L50
#ifdef _MSC_VER
#include <stdlib.h>
#define bswap_32(x) _byteswap_ulong(x)
#define bswap_64(x) _byteswap_uint64(x)
#elif defined(__APPLE__)
// Mac OS X / Darwin features
#include <libkern/OSByteOrder.h>
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)
#elif defined(__sun) || defined(sun)
#include <sys/byteorder.h>
#define bswap_32(x) BSWAP_32(x)
#define bswap_64(x) BSWAP_64(x)
#elif defined(__FreeBSD__)
#include <sys/endian.h>
#define bswap_32(x) bswap32(x)
#define bswap_64(x) bswap64(x)
#elif defined(__OpenBSD__)
#include <sys/types.h>
#define bswap_32(x) swap32(x)
#define bswap_64(x) swap64(x)
#elif defined(__NetBSD__)
#include <sys/types.h>
#include <machine/bswap.h>
#if defined(__BSWAP_RENAME) && !defined(__bswap_32)
#define bswap_32(x) bswap32(x)
#define bswap_64(x) bswap64(x)
#endif
#else
#include <byteswap.h>
#endif
I'm not aware of a cross-platform and efficient way of doing that. If you use GCC you can use the builtin byteswap like:
uint32_t __builtin_bswap32 (uint32_t x)
Those are fast but certainly not portable... unless you wrap the various versions under the appropriate ifdefs
Cheers
Francesco
I am compiling following simple code in ffmpeg.
#include "stdafx.h"
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
void main()
{
av_register_all();
}
all the ffmpeg headers i have included in project properties.
but i am getting the following error on compiling.
Error 1 error C1004: unexpected end-of-file found dev\include\libavutil\common.h 87 1
Regards
Mayank
Try define __STDC_CONSTANT_MACROS before including those headers to see if problem can be solved.
#include "stdafx.h"
extern "C" {
#define __STDC_CONSTANT_MACROS
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
};
See http://bigbang.waterlin.org/bang/using-ffmpeg-under-windows-visual-cpp-environment/
Regards zcy
Here is the simple echo.c source code:
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT(
"#(#) Copyright (c) 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "#(#)echo.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: echo.c,v 1.7 1997/07/20 06:07:03 thorpej Exp $");
#endif
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main __P((int, char *[]));
int
main(argc, argv)
int argc;
char *argv[];
{
/*
*main code with no error at all
*/
}
When compiling it with gcc 4.4.6, it report errors:
echo.c:4: error: expected declaration specifiers or â...â before string constant
echo.c:3: warning: data definition has no type or storage class
echo.c:12: error: expected declaration specifiers or â...â before string constant
echo.c:12: warning: data definition has no type or storage class
Line 3 and 4 is __COPYRIGHT macro.
Line 12 is __RCSID macro.
If I delete these two macro, it compiles successfully and runs correctly.
After some googling, I know that these two macros are defined in sys/cdefs.h and they are some kind of comment message.
But why it won't compile in gcc?
Well after going throuhg sys/cdefs.h (ubuntu 11.10), I found no __COPYRIGHT or __RCSID defination.
So I guess these two macros are defined in NetBSD sys/cdefs.h.
I added them in a new header file (I name it with "aeodefs.h") like the following:
#ifndef _AEODEFS_H_
#define _AEODEFS_H_
#include <sys/cdefs.h>
#define __IDSTRING(name,string) \
static const char name[] __attribute__((__unused__)) = string
#ifndef __RCSID
#define __RCSID(s) __IDSTRING(rcsid,s)
#endif
#ifndef __COPYRIGHT
#define __COPYRIGHT(s) __IDSTRING(copyright,s)
#endif
#endif /* !_AEODEFS_H_ */
Then change #include <sys/cdefs.h> to #include "aeodefs.h".
It's done!