I'm following this blog to make a C++ package using SPM: http://ankit.im/swift/2016/05/21/creating-objc-cpp-packages-with-swift-package-manager/
But am getting this error when building:
swift build
'SwiftCpp' /home/karthik/Swift_programs/SwiftCpp: error: target at '/home/karthik/Swift_programs/SwiftCpp/Sources' contains mixed language source files; feature not supported
I'm using Swift version 4.2.3 on Ubuntu 18.04 LTS.
Here's the code :
main.cpp
#include <iostream>
#include "cpplib.h"
int main() {
std::cout << cpplib::five();
return 0;
}
cpplib.cpp
#include "include/cpplib.h"
namespace cpplib {
int five(){
return 5;
}
}
cpplib.h
namespace cpplib{
int five();
}
cwrapper.cpp
#include "include/cwrapper.h"
#include "cpplib.h"
int cwrapperfive(){
return cpplib::five();
}
cwrapper.h
#ifdef __cplusplus
extern "C" {
#endif
int cwrapperfive();
#ifdef __cplusplus
}
#endif
main.swift
import cwrapper
print(cwrapperfive())
How can I solve this?