Hello everyone, I hope you are doing well! I’m having a problem when I try to run a simple pythia generation program. This is my code:
#include "Pythia8/Pythia.h"
using namespace Pythia8;
int main() {
// Configuração do processo:
Pythia pythia; // Declara 'pythia' como um objeto do tipo Pythia
pythia.readString("Top:ffbar2W = on"); // Seleciona o processo
pythia.readString("Beams:eCM = 8000."); // 8 TeV CM
pythia.init(); //Inicializa o processo
// Geração do evento:
pythia.next(); // Gera o evento
return 0;
}
I got this message when I try to run it:
[14:42:34] [~/Documentos/Physics/IC/Programas] $ g++ ffbar2W.c -lpythia8 -ldl
ffbar2W.c:1:28: fatal error: Pythia8/Pythia.h: File or directory not found
#include "Pythia8/Pythia.h"
^
compilation terminated.
I have a Ubuntu 14.04.5 LTS (x86_64), my C++ compiler is g++ 4.8.4 and I’m using Pythia 8.2
Ps:The comment lines are in portuguese, please just ignore it
You need to tell the compiler where to find the headers for Pythia.
For example, if Pythia.h is in /usr/local/include/Pythia8/Pythia.h, then you need to pass the option -I/usr/local/include to the compiler. Also, make sure to use ROOT’s flags as well, with
[15:29:58] [~/Documentos/Physics/IC/Programas] $ g++ $(root-config --cflags --libs) -I/~/IC/pythia8226/include/Pythia8 ffbar2W.c -lpythia8 -ldl
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 0 tem um índice de símbolo inválido 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 1 tem um índice de símbolo inválido 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 2 tem um índice de símbolo inválido 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 3 tem um índice de símbolo inválido 2
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 4 tem um índice de símbolo inválido 11
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 5 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 6 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 7 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 8 tem um índice de símbolo inválido 12
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 9 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 10 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 11 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 12 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 13 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 14 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 15 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 16 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 17 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 18 tem um índice de símbolo inválido 13
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): realocação 19 tem um índice de símbolo inválido 21
/usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_line): realocação 0 tem um índice de símbolo inválido 2
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o: na função `_start':
(.text+0x20): referência indefinida para `main'
collect2: error: ld returned 1 exit status
Ah, you probably only have a function inside your macro, with the same name as the file. When you run with ROOT, you can do that, but when you compile, it’s like a regular C++ program, so you need to create an int main() function, which is the usual starting function for any program.