0

I am a complete beginner in C++ and trying to run my first program.

#include <iostream>

int main()
{
    std::cout << "Hello world!";
    return 0;
}

Then I run, in the terminal:

g++ first.cpp

But it gives me this error:

/home/shikhar/anaconda3/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_exception_create@GLIBC_PRIVATE'
/home/shikhar/anaconda3/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_audit_symbind_alt@GLIBC_PRIVATE'
/home/shikhar/anaconda3/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_audit_preinit@GLIBC_PRIVATE'
/home/shikhar/anaconda3/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_find_dso_for_object@GLIBC_PRIVATE'
/home/shikhar/anaconda3/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `_dl_fatal_printf@GLIBC_PRIVATE'
/home/shikhar/anaconda3/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `__nptl_change_stack_perm@GLIBC_PRIVATE'
/home/shikhar/anaconda3/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: undefined reference to `__tunable_get_val@GLIBC_PRIVATE'

I am using Linux Mint 21.2. \

I am unable to understand any solutions on the internet for similar errors.

13
  • 1
    Try g++ first.cpp -ldl. Commented Aug 22, 2023 at 4:28
  • 1
    Those linker errors seems odd for that simple program. How did you install the compiler and the system development files? Have you set up anything special in the terminal for development? Is perhaps g++ an alias for something else? Commented Aug 22, 2023 at 4:34
  • @HolyBlackCat that doesn't work. Commented Aug 22, 2023 at 4:36
  • 2
    Try not to use binutils from conda. For example, run conda deactivate first. Commented Aug 22, 2023 at 4:37
  • 2
    Anaconda sets some environment variables, for example $LD_LIBRARY_PATH, which interferes with the execution of your program. Commented Aug 22, 2023 at 4:42

1 Answer 1

1

The problem was using the compiler through anaconda. Deactivating anaconda then compiling worked.

conda deactivate
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.