I'm working on porting a windows project to linux so I am trying to learn/setup my build pipeline on linux(ubuntu). I use clang on windows and would like to use clang/llvm to compile my code on ubuntu but I am having an issue linking the c runtime library to my code. Here's an example of what I am trying to run just so I can set up the build scripts,
#include <stdio.h>
#include <stdlib,h
#include <string.h>
int main() {
char title[] = "Text";
int title_length = strlen(title);
return(0); }
After installing clang 3.4 on Ubuntu 14.04 LTS I run from the terminal,
clang++ -c main.cpp
The file compiles without error. I use the following command when trying to link,
ld main.o
I get back the following error every single time,
ld: warning: cannot find entry symbol _start; defaulting to 00000000004000b0
In function 'main':
(.text+0x30): undefined reference to 'strlen'
I try linking libc++, libstdc++ but nothing seems to work. I am admittedly very, very new to linux and clang on linux so I apologize in advance. I have checked different questions here on stackoveflow as well as ubuntu's forums and LLVM's forums/docs to no avail. If anyone could point me in the right direction it would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire