Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9153749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:19:24+00:00 2026-06-17T12:19:24+00:00

To teach myself a little C++, I decided to write a little Program to

  • 0

To teach myself a little C++, I decided to write a little Program to write text to my Saitek X52 Pro joystick display.

I wanted to use Eduards C-library
http://plasma.hasenleithner.at/x52pro/

I know I have to place an “extern C” around the methods if I want to use them in my C++ program. But that means changing the Header file of the library – and then it wouldn’t build anymore.
What would be the correct approach in this case?

EDIT: the suggested method worked partially.

Comm.cpp:

...
extern "C"{
#include <x52pro.h>
}
using namespace std;
int main ( int argc, char *argv[] ) {
    cout<<"entered main"<<endl;
    char *String;
    strcpy(String,"testing");
    struct x52 *hdl = x52_init();
    x52_settext(hdl, 0,String , 7);
    x52_close(hdl);
    return EXIT_SUCCESS;
}

Error Message:

Comm.o: In function `main': 
Comm.cpp|38| undefined reference to `x52_init' 
Comm.cpp|39| undefined reference to `x52_settext' 
Comm.cpp|40| undefined reference to `x52_close'

which are all methods defined in x52pro.h

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:19:25+00:00Added an answer on June 17, 2026 at 12:19 pm

    To use extern "C" in C header files, wrap it so

    #ifdef __cplusplus
    extern "C" {
    #endif
    ...
    #ifdef __cplusplus
    }
    #endif
    

    or you can wrap the #includes with extern "C"

    extern "C" {
    #include <chdr1.h>
    #include <chdr2.h>
    }
    

    When linking your application, you must tell the linker what library to use and where the library is. From your link, you must add libusb as well. This looks roughly like this

    g++ -o app_name Comm.o -L /path/to/library -lx52pro -lusb
    

    When the library is installed in the system lib directory, you can omit the -L /path/... part. If you use a Makefile, you define this in some variables, usually

    LDFLAGS = -L /path/to/library
    LDLIBS = -lx52pro -lusb
    

    See also Compiling and Linking and Wikipedia – Linker (computing)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I decided to teach myself how to use Parsec , and I've hit a
When I decided to teach myself to program, I started with Java. And although
I decided to teach myself assembly language. I have realized that my program will
I'm working on a little fitness tracker in order to teach myself Django. I
I'm trying to teach myself to program stepper motors. I am a beginner at
I'm just trying to teach myself how to use Linq. This is what I
Am attempting to teach myself to program using Tcl. The task i've set myself
Am attempting to teach myself to program using Tcl. (I want to become more
I am trying to teach myself how to use SQL, namely mysql. What I
I'm trying to teach myself fortran so I can unravel an old program and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.