Bug 86304

Summary: [PATCH] graphics/jpeg does not have 'extern "C"' for C++
Product: Ports & Packages Reporter: Craig Rodrigues <rodrigc>
Component: Individual Port(s)Assignee: Dirk Meyer <dinoex>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

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.