macOS basic makefile

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
tcgessner
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Jul 30, 2020 10:14 am

macOS basic makefile

Post by tcgessner » Thu Jul 30, 2020 10:21 am

I am using CMake to build a basic (HelloWorld) wxWidgets app. The compiler is clang/llvm and I am using visual studio code as the editor.

CMake successfully builds the makefile but I get a link error when building HelloWorld.

error: expected unqualified-id @class NSString Protocol;

I'm not sure what I am doing wrong. Can anyone point me in the right direction?


my cpp file:
#include <iostream>

#include <wx.h>


int main()
{
std::cout << "HelloWorld" << std::endl;
}


wxWidgets 3.0.5 cmake 3.18.0 macOS 10.15.6

Here is my cmake txt file:
cmake_minimum_required(VERSION 3.0.0)
project(HelloWorld VERSION 0.1.0)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

include(CTest)
enable_testing()

add_executable(HelloWorld HelloWorld.cpp)

add_library(wx_baseu STATIC IMPORTED)
set_target_properties(wx_baseu PROPERTIES IMPORTED_LOCATION /Users/tim/Onedrive/Programming/wxWidgets-3.0.5/lib/libwx_baseu-3.0.a)

add_library(wx_osx_cocoau_core STATIC IMPORTED)
set_target_properties(wx_osx_cocoau_core PROPERTIES IMPORTED_LOCATION /Users/tim/Onedrive/Programming/wxWidgets-3.0.5/lib/libwx_osx_cocoau_core-3.0.a)

target_link_libraries(HelloWorld wx_baseu wx_osx_cocoau_core)

target_include_directories(HelloWorld PUBLIC /Users/tim/Onedrive/Programming/wxWidgets-3.0.5/include/wx/cocoa)


set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4245
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: macOS basic makefile

Post by ONEEYEMAN » Thu Jul 30, 2020 4:26 pm

Hi,
Do you need the basic console application or a GUI one?
Can you successfully build and run the minimal sample or console sample depending on the answer above?
And how did you build wxWidgets?

Thank you.

tcgessner
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Jul 30, 2020 10:14 am

Re: macOS basic makefile

Post by tcgessner » Fri Jul 31, 2020 8:55 am

Hello I wanted to build a gui application (the tutorial HelloWorld)

to build wxwidgets I used
$ ../wxWidgets/configure --with-cocoa --enable-debug --disable-shared
$ make
$ cd samples/minimal
$ make
$ ./minimal.app/Contents/MacOS/minimal

both succeeded and I can run minimal.

Thanx

tcgessner
In need of some credit
In need of some credit
Posts: 6
Joined: Thu Jul 30, 2020 10:14 am

Re: macOS basic makefile

Post by tcgessner » Fri Jul 31, 2020 8:57 am

I did change

target_include_directories from .../include/wx/cocoa to just .../include

Thanx

Post Reply