Dear list,

I have some trouble with my C++ code blocks, and exporting them to LaTeX. My version is current git HEAD.

There are two issues:

1) LaTeX Export: For some reason, the babel language name gets parts of the compiler :flags mixed in, resulting in bad LaTeX code such as this:

\begin{minted}[]{cpp"-L/usr/local/cuda/lib"}   % <-- HERE
#include <iostream>
int main(int argc, char** argv){
     std::cout << "Hello World" << std::endl;
}
\end{minted}

This behavior is the same for lstlistings and minted type, but (obviously) does not affect verbatim.

2) Not sure if anyone else has this issue, but for linking a c++ file with g++, I need to specify the linker libraries AFTER the cpp file I'm trying to compile. For me, this could be resolved by switching the order of the arguments to (format...) in ob-C.el. Is there any reason why the order is as it is?

A minimal example is included below.

yours,

  Hannes



==================== snip =======================
#+TITLE:     Test
#+LaTeX_HEADER: \usepackage{minted}
#+LaTeX_HEADER: \usemintedstyle{borland}
#+latex_header: \usepackage{color}
#+latex_header: \renewcommand{\maketitle}{}
#+LANGUAGE:  en
#+OPTIONS:   H:3 num:nil toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
#+LaTeX_CLASS: article
#+LaTeX_CLASS_OPTIONS: [english,final]
#+begin_src emacs-lisp :exports none :results silent
  ; work with minted
  (setq org-latex-listings 'minted)
#+end_src

* Test

#+begin_src cpp :exports code :flags "-L/usr/lib -lcblas"
  #include <iostream>
  
  int main(int argc, char** argv){
       std::cout << "Hello World" << std::endl;
  }
#+end_src

#+RESULTS:
: Hello World
==================== snap =======================