Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7663 Discussions

Static library linkage failure with enabled IPO on ICX

fatvlad1744
Beginner
151 Views

Hi,

 

I'm trying to have two-stage compilation where I create static library first and link it afterwards.

// main.cpp
void foo();

int main() {
    foo();
}

// foo.cpp
#include <iostream>

void foo() {
    std::cout << "Hi foo!" << std::endl;
}

Compilation:

$ icpx -fast -c -o foo.o foo.cpp
$ xiar rcs libfoo.a foo.o
xiar: executing 'ar'
$ icpx -fast main.cpp -L. -lfoo
/usr/bin/ld: skipping incompatible ./libfoo.a when searching for -lfoo
/usr/bin/ld: cannot find -lfoo
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Seems like it fails to parse static library format when IPO is enabled. When IPO is disabled, everything is fine. Also, classic ICC compiler works fine.

However, when using direct linkage with object file, everything seems to work fine:

$ icpx -fast main.cpp foo.o
$ ./a.out 
Hi foo!

Can you please clarify how to fix that? I'm using CentOS 7:

  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-1127.8.2.el7.x86_64
      Architecture: x86-64

Thanks in advance.

0 Kudos
0 Replies
Reply