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 8958977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:20:29+00:00 2026-06-15T15:20:29+00:00

I have an example code: #include <quadmath.h> int main() { __float128 foo=123; cosq(foo); return

  • 0

I have an example code:

#include <quadmath.h>

int main()
{
    __float128 foo=123;
    cosq(foo);
    return 0;
}

I tried to compile it with the following commands:

g++ f128.cpp -lquadmath
g++ f128.cpp /usr/lib64/gcc/x86_64-suse-linux/4.6/libquadmath.a
g++ f128.cpp /usr/lib64/gcc/x86_64-suse-linux/4.6/libquadmath.a /usr/lib64/libquadmath.so.0
g++ f128.cpp /usr/lib64/gcc/x86_64-suse-linux/4.6/libquadmath.a /usr/lib64/libquadmath.so.0 /usr/lib64/gcc/x86_64-suse-linux/4.6/libquadmath.a

All these commands produce one and the same error:

f128.cpp:(.text+0x1b): undefined reference to `cosq(__float128)'

I also tried to declare cosq as follows, without inluding quadmath.h. Declarations of such style are used in C++ interface to fortran subroutines in other programs, and they work well.

extern "C" __float128 cosq_(__float128 *op);
extern "C" __float128 cosq_(__float128 op);
extern "C" __float128 cosq(__float128 *op);
...and so on...

Result was the same.

Then I tried to use cosq in Fortran:

PROGRAM test

        REAL*16 foo
        REAL*16 res

        foo=1;
        res=cos(foo)
        PRINT *,res
END

This program compiles and executes well (prints the answer with lots of digits), so cosq works in it. This program was compiled with no options: gfortran f128.f90.

OS is OpenSUSE 12.1, gcc version is 4.6.2. *.h, *.a and *.so files mentioned are provided by gcc46-fortran and libquadmath46 packages.

What is the proper way to use cosq and other quadmath functions in C++? I wouldn’t like to write Fortran wrappers for them.

  • 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-15T15:20:31+00:00Added an answer on June 15, 2026 at 3:20 pm

    First, according to Nikos C. advise, I boot up OpenSUSE 12.2 liveCD (which has gcc 4.7.1) on another machine, but got the same error.

    Then I posted this question to OpenSUSE forums.

    Martin_helm’s answer shows that the problem is distro-independent and the solution is trivial:

    extern "C" {
    #include <quadmath.h>
    }
    

    This works fine on all my machines. Program can be compiled with g++ prog.cpp -lquadmath.

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

Sidebar

Related Questions

So I have the following test code: #include <string.h> #include <stdio.h> int main(int argc,
I have a program that has this code : #include<stdio.h> main(){ int input; char
Let's take this example code: #include <stdio.h> int main(void){ int x = 1; if(*(char
I have this example code that doesn't compile: #include <iostream> #include <vector> using std::endl;
I have the following bit of code (it's example code, so nothing fancy): #include
I have the following code: #include <iostream> using namespace std; struct S { S(int
have a look at this code: #include<stdio.h> #include <unistd.h> int main() { int pipefd[2],n;
I have the following example code: $dataProvider = new CActiveDataProvider('firstTable', array('criteria' => array( 'select'
Code snippet to follow. I have a struct (example code has class, tried both,
In the next code: #include <stdio.h> int main(void) { int c; while ((c=getchar())!= EOF)

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.