The static library is successfully connected by GCC, and the G ++ fails to connect to the static library.

Source: Internet
Author: User
Original article: Missing undefined reference to 'error. The library function cannot be found. Main. c :(. text + 0x15): Undefined reference to 'memorycontextinit () 'main. c :(. text + 0x26): Undefined reference to 'memorycontextdestory () 'can be compiled using gcc. In fact, the Code is not an object-oriented C ++ language, and I didn't think of it as a problem where c ++ calls C functions. At first, the path of the database is incorrect; the database sequence in the make file is incorrect; and other methods have no effect. The extern "C" problem was discovered only after a hundred attempts. You can use g ++ to compile C's library functions. The target file. O can be generated, but the C ++ naming mechanism has changed the name of the called library function. It must be added with the extern "C" before the C library function ". If one function is converted one by one, it is feasible to extern "C" memorycontextinit (); however, to be able to perform a full conversion, you can change the header file reference of the entire library to the following method: extern "C" {# include ".. /lib/libxxx. h.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.