jarro2783 / cxxopts

Lightweight C++ command line option parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

use woes under opensuse // Kdevelop

seuchato opened this issue · comments

Hi
I followed the install instructions to the letter. Also built the tests successfully. Now I'd like to build a command line app to process some audio files ("wav" for now only).
The app should plot spectra and phase for all individual channels plus a sum spectra with sum phase. The options I'd like to have, is select channels individually ("-c=x" where x is the channel No) or sum only ("-sum"). There will follow be some options to format the output, but that is irrelevant in the context of the problem I have to sort out, I guess.

The very Problem:

`#include

#include "./cxxopts-master/include/cxxopts.hpp"

int main(int argc, char **argv) {

cxxopts::Options options("test", "A brief description");

options.add_options()
    ("s,sum", "Enable sum spectra & phase output", cxxopts::value<bool>()->default_value("true"))
    ("i,infile", "Input file name", cxxopts::value<std::string>())
    ("c", "Channel", cxxopts::value<int>()->default_value("10"))
    ("h,help", "Print usage")
    ("o,outfile", "Output file name", cxxopts::value<std::string>())
;

auto result = options.parse(argc, argv);

if (result.count("help"))
{
  std::cout << options.help() << std::endl;
  exit(0);
}
bool debug = result["debug"].as<bool>();
std::string bar;
if (result.count("bar"))
  bar = result["bar"].as<std::string>();
int foo = result["foo"].as<int>();

std::cout << "Hello, world!" << std::endl;

return 0;

}
`
If I click on "Build" I get :

/home/users/me/projects/spectan/spectan/build> make -j4 -- Configuring done -- Generating done -- Build files have been written to: /home/users/me/projects/spectan/spectan/build Consolidate compiler generated dependencies of target spectan [ 50%] Building CXX object CMakeFiles/spectan.dir/main.cpp.o [100%] Linking CXX executable spectan /usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: cannot find -lcxxopts: No such file or directory collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/spectan.dir/build.make:97: spectan] Error 1 make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/spectan.dir/all] Error 2 make: *** [Makefile:136: all] Error 2 *** Fehler: Beendigungscode 2 ***

here is my project's CMakeList.txt (also done in KDevelop):
`cmake_minimum_required(VERSION 3.0)

project(spectan)
)

add_executable(spectan main.cpp)

target_link_libraries(spectan cxxopts)

install(TARGETS spectan RUNTIME DESTINATION bin)`

Any suggestions what is wrong here?
greeez
chris

... seems I have it sorted out. Started a new project from scratch. In KDevelop, this time I chose "Standart/Terminal/C++(17/14) with CMake and a custom header".

Now it compiles and runs, prints usage message : all good! :)

Thanks
chrsi