を使用して簡単な TUI を作成しようとしていnewt
ます。newt-dev パッケージをインストールしました。次のコマンドapt-get install libnewt-dev
を使用してビルドすると、正常に動作するため、正しくインストールされていると思います。gcc
gcc -o test main.cpp -lnewt
cmake
しかし、 newを使用しようとすると、私の単純なコードはコンパイルされませんCLion IDE
。ソース コード、CMakeLists.txt、およびコンパイラ出力は次のとおりです。
#include <newt.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[])
{
/* required variables and string */
int uiRows, uiCols;
const char pcText[] = "Welcome to Newt and FLOSS !!!";
/* initialization stuff */
newtInit();
newtCls();
/* determine current terminal window size */
uiRows = uiCols = 0;
newtGetScreenSize(&uiCols, &uiRows);
/* draw standard help and string on root window */
newtPushHelpLine(NULL);
newtDrawRootText((uiCols-strlen(pcText))/2, uiRows/2, pcText);
/* cleanup after getting a keystroke */
newtWaitForKey();
newtFinished();
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 3.1)
project(TemparatureMonitoring)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_library(newt) #this does nothing!
set(SOURCE_FILES main.cpp)
add_executable(TemparatureMonitoring ${SOURCE_FILES})
コンパイラ出力:
/opt/clion-1.0/bin/cmake/bin/cmake --build /home/saeid/.clion10/system/cmake/generated/9c100db8/9c100db8/Debug --target all -- -j 4
You have called ADD_LIBRARY for library newt without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
CMake Error: Cannot determine link language for target "newt".
CMake Error: CMake can not determine linker language for target: newt
-- Generating done
-- Build files have been written to: /home/saeid/.clion10/system/cmake/generated/9c100db8/9c100db8/Debug
make: *** [cmake_check_build_system] Error 1
どうにかして newt パッケージへの参照を追加する必要があると思いますが、方法がわかりません! だから基本的に私はforの-l
スイッチに相当するものを探していますgcc
CMakeLists.txt