Thread: calling C functions from C++ code

  1. #31
    Registered User
    Join Date
    Oct 2011
    Posts
    29
    Quote Originally Posted by jimblumberg View Post
    Where did you find "your" C code? Are there other files or functions that came with "your" C code? "Your" C code looks to me like it may be part of a larger code base meant to be used as a library, not necessarily a stand alone function.

    Jim
    Oh it's not mine at all. I've got my C++ code that's trying to use certain functions from libav. I found some example code online:

    FFmpeg: libavformat/output-example.c Source File

    All I did was break that up into a .h and a .c file so I can include the .h in my code and see if I can call on those functions. If I accidentally said that it was my code, I apologize for the misunderstanding.

    The errors I'm getting are with the libraries the C code includes (so a lot of weird syntax errors) such as:

    Code:
    libavutil\common.h(193): error C2054: expected '(' to follow 'inline'
    I downloaded the library, too and have it included in the project as a whole.

  2. #32
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    What operating system are you using? What compiler are you using? How did you compile the FFmpeg library? How are you trying to add this library to your project?

    Jim

  3. #33
    Registered User
    Join Date
    Oct 2011
    Posts
    29
    Quote Originally Posted by jimblumberg View Post
    What operating system are you using? What compiler are you using? How did you compile the FFmpeg library? How are you trying to add this library to your project?

    Jim
    I'm using Windows 7 (there is part of the code that is neither ffmpeg related, nor mine, that I'm having to integrate with, which is why, earlier, just disabling PCH for the entire project wasn't a choice), Not sure about the compiler, I'm using VC++ 2010.

    I did not compile the library myself. Downloaded it from:

    Zeranoe FFmpeg - Builds

    Got the 32bit dev version and the dll's from a shared version. I added the include directory to my Project's include directories and same with the lib directory. I had something simpler before and got it to compile and run, but now that I'm including an entire new file, which is in C, not C++, just to see if I can get it to run as an example, I have run into these new problems.

  4. #34
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    I don't see a version of this library that was built using Visual Studio. Also did you read the documentation for FFmpeg? Did you read the FAQ. This section really seems to be applicable to your problem. And here is a direct quote:
    4.3 Is Microsoft Visual C++ supported?

    No. Microsoft Visual C++ is not compliant to the C99 standard and does not - among other things - support the inline assembly used in FFmpeg. If you wish to use MSVC++ for your project then you can link the MSVC++ code with libav* as long as you compile the latter with a working C compiler. For more information, see the Microsoft Visual C++ compatibility section in the FFmpeg documentation.

    There have been efforts to make FFmpeg compatible with MSVC++ in the past. However, they have all been rejected as too intrusive, especially since MinGW does the job adequately. None of the core developers work with MSVC++ and thus this item is low priority. Should you find the silver bullet that solves this problem, feel free to shoot it at us.

    We strongly recommend you to move over from MSVC++ to MinGW tools.
    So I would say you will probably never get this working correctly with MSVC.

    Jim

  5. #35
    Registered User
    Join Date
    Oct 2011
    Posts
    29
    Quote Originally Posted by jimblumberg View Post
    I don't see a version of this library that was built using Visual Studio. Also did you read the documentation for FFmpeg? Did you read the FAQ. This section really seems to be applicable to your problem. And here is a direct quote:


    So I would say you will probably never get this working correctly with MSVC.

    Jim
    Oh. I must've missed that part. Yes I'm not used to programming on windows, so I guess I took it for granted that ffmpeg would work... Now it makes sense. Back to the drawing board I guess. Much appreciated.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calling functions
    By cda67 in forum C Programming
    Replies: 2
    Last Post: 10-14-2011, 11:56 PM
  2. Help calling and using a functions
    By method in forum Windows Programming
    Replies: 0
    Last Post: 07-08-2006, 04:08 PM
  3. calling functions & assembly code
    By Micko in forum C++ Programming
    Replies: 1
    Last Post: 02-25-2004, 03:27 PM
  4. calling functions::
    By Yoshi in forum C++ Programming
    Replies: 1
    Last Post: 12-13-2002, 02:34 PM
  5. Functions calling themselves...?
    By mikebrewsj in forum C++ Programming
    Replies: 10
    Last Post: 01-18-2002, 12:09 AM

Tags for this Thread