Bug 86304 - [PATCH] graphics/jpeg does not have 'extern "C"' for C++
Summary: [PATCH] graphics/jpeg does not have 'extern "C"' for C++
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Dirk Meyer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-18 20:20 UTC by Craig Rodrigues
Modified: 2005-09-22 08:02 UTC (History)
0 users

See Also:


Attachments
file.diff (738 bytes, patch)
2005-09-18 20:20 UTC, Craig Rodrigues
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Rodrigues 2005-09-18 20:20:03 UTC
	If jpeglib.h is included in a C++ program, the functions in
	libjpeg cannot be linked against, because the function prototypes
	are not decorated with 'extern "C"'

Fix: The fix is to re define the EXTERN macro if you are compiling with
a C++ compiler.

How-To-Repeat: If you put the following code snippet:
#include <stdio.h>
#include "jpeglib.h"
int main(int argc, char *argv[]) { jpeg_std_error(NULL); }

in a C file (test.c), and compile with:
gcc -I/usr/local/include test.c -L/usr/local/lib -ljpeg

it will compile and link fine.

If you rename the file to test.cpp, and compile with:
g++ -I/usr/local/include test.cpp -L/usr/local/lib -ljpeg

You will get a link error:
: undefined reference to `jpeg_std_error(jpeg_error_mgr*)'
Comment 1 Craig Rodrigues freebsd_committer freebsd_triage 2005-09-18 20:21:07 UTC
Responsible Changed
From-To: freebsd-ports-bugs->dinoex

Assigning to port maintainer.
Comment 2 Dirk Meyer freebsd_committer freebsd_triage 2005-09-22 08:01:58 UTC
State Changed
From-To: open->closed

committed, thanks.